@@ -46,6 +46,8 @@ class ApiClient(object):
46
46
HEADER_GEOLOCATION = 'X-Bunq-Geolocation'
47
47
HEADER_SIGNATURE = 'X-Bunq-Client-Signature'
48
48
HEADER_AUTHENTICATION = 'X-Bunq-Client-Authentication'
49
+ HEADER_RESPONSE_ID_UPPER_CASED = 'X-Bunq-Client-Response-Id'
50
+ HEADER_RESPONSE_ID_LOWER_CASED = 'x-bunq-client-response-id'
49
51
50
52
# Default header values
51
53
_USER_AGENT_BUNQ = 'bunq-sdk-python/0.12.4'
@@ -222,7 +224,8 @@ def _assert_response_success(self, response):
222
224
if response .status_code != self ._STATUS_CODE_OK :
223
225
raise ExceptionFactory .create_exception_for_response (
224
226
response .status_code ,
225
- self ._fetch_error_messages (response )
227
+ self ._fetch_error_messages (response ),
228
+ self ._fetch_response_id (response )
226
229
)
227
230
228
231
@classmethod
@@ -266,6 +269,25 @@ def _fetch_error_descriptions(self, error_dict):
266
269
267
270
return error_descriptions
268
271
272
+ def _fetch_response_id (self , response ):
273
+ """
274
+ :type response: requests.Response
275
+
276
+ :rtype: str
277
+ """
278
+
279
+ headers = response .headers
280
+
281
+ if self .HEADER_RESPONSE_ID_UPPER_CASED in headers :
282
+ return headers [self .HEADER_RESPONSE_ID_UPPER_CASED ]
283
+
284
+ if self .HEADER_RESPONSE_ID_LOWER_CASED in headers :
285
+ return headers [self .HEADER_RESPONSE_ID_LOWER_CASED ]
286
+
287
+ return exception .BunqException (
288
+ self ._ERROR_COULD_NOT_DETERMINE_RESPONSE_ID_HEADER
289
+ )
290
+
269
291
def put (self , uri_relative , request_bytes , custom_headers ):
270
292
"""
271
293
:type uri_relative: str
0 commit comments