Skip to content
Snippets Groups Projects

OM46, del 1: Support batch_complete endpoint from setra

Merged Petr.Kalashnikov requested to merge om46 into master
Files
8
+ 25
1
@@ -37,13 +37,15 @@ class SetraEndpoints:
batch_url='api/batch/',
transaction_url='api/transaction/',
voucher_url='api/voucher/',
new_batch_url='api/addtrans/'
new_batch_url='api/addtrans/',
batch_complete_url='api/batch_complete/'
):
self.baseurl = url
self.batch_url = batch_url
self.transaction_url = transaction_url
self.voucher_url = voucher_url
self.new_batch_url = new_batch_url
self.batch_complete_url = batch_complete_url
""" Get endpoints relative to the SETRA API URL. """
@@ -86,6 +88,16 @@ class SetraEndpoints:
def post_new_batch(self):
return urllib.parse.urljoin(self.baseurl, self.new_batch_url)
def batch_complete(self, batch_id: str = None):
"""
URL for Batch endpoint
"""
if batch_id is None:
return urllib.parse.urljoin(self.baseurl, self.batch_complete_url)
else:
return urllib.parse.urljoin(self.baseurl,
'/'.join((self.batch_complete_url, batch_id)))
class SetraClient(object):
default_headers = {
@@ -209,6 +221,18 @@ class SetraClient(object):
return_response=return_response)
return response
def get_batch_complete(self, batch_id: int = None):
"""
GETs one or all batches from SETRA
"""
if batch_id is not None:
batch_id = str(batch_id)
url = self.urls.batch_complete(batch_id)
response = self.get(url)
return response.json()
def get_client(config_dict):
"""
Loading