Skip to content
Snippets Groups Projects
Commit 1c20529d authored by Andreas Ellewsen's avatar Andreas Ellewsen
Browse files

Return more info from post and put methods

Before this commit it was unclear whether a post request was successful
or not. We now return the content and status to make this clearer
parent e38940f5
No related branches found
No related tags found
1 merge request!18Clarify responses from post/put
Pipeline #86964 passed
......@@ -288,8 +288,10 @@ class SetraClient(object):
data=batchdata.json(),
headers=headers,
return_response=True)
if response.status_code in (409, 202):
return 'OK'
if response.status_code == 202:
return response.content, 'Accepted'
elif response.status_code == 409:
return response.content, "Conflict"
else:
response.raise_for_status()
return response
......@@ -298,19 +300,19 @@ class SetraClient(object):
"""
PUT updates an existing batch with vouchers and transactions,
if the batch exists in setra, and has status=created, or validation failed.
Returns 404 if no batch was found, 202 for successful update, or 409 if batch was found, but
did not meet the status criteria mentioned above.
Returns 404 if no batch was found, 204 for successful update, or 409 if batch
was found, but did not meet the status criteria mentioned above.
"""
url = self.urls.put_update_batch()
headers = {'Content-Type': 'application/json'}
response = self.put(url,
data=batchdata.json(),
headers=headers,
return_response=True)
if response.status_code in (204, 202):
return 'OK'
data=batchdata.json(),
headers=headers,
return_response=True)
if response.status_code == 204:
return response.content, 'No Content'
elif response.status_code == 409:
return 'batch_found_but_cannot_be_updated'
return response.content, 'batch_found_but_cannot_be_updated'
else:
response.raise_for_status()
return response
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment