@@ -19,6 +19,9 @@ class ApiClient(object):
1919 :type _api_context: context.ApiContext
2020 """
2121
22+ # HTTPS type of proxy, the only used at bunq
23+ _FIELD_PROXY_HTTPS = 'https'
24+
2225 # Header constants
2326 HEADER_ATTACHMENT_DESCRIPTION = 'X-Bunq-Attachment-Description'
2427 HEADER_CONTENT_TYPE = 'Content-Type'
@@ -32,7 +35,7 @@ class ApiClient(object):
3235 HEADER_AUTHENTICATION = 'X-Bunq-Client-Authentication'
3336
3437 # Default header values
35- _USER_AGENT_BUNQ = 'bunq-sdk-python/0.9 '
38+ _USER_AGENT_BUNQ = 'bunq-sdk-python/0.10.0 '
3639 _GEOLOCATION_ZERO = '0 0 0 0 NL'
3740 _LANGUAGE_EN_US = 'en_US'
3841 _REGION_NL_NL = 'nl_NL'
@@ -66,7 +69,7 @@ def post(self, uri_relative, request_bytes, custom_headers):
6669 :type request_bytes: bytes
6770 :type custom_headers: dict[str, str]
6871
69- :return: requests.Response
72+ :return: BunqResponseRaw
7073 """
7174
7275 return self ._request (
@@ -83,7 +86,7 @@ def _request(self, method, uri_relative, request_bytes, custom_headers):
8386 :type request_bytes: bytes
8487 :type custom_headers: dict[str, str]
8588
86- :return: requests.Response
89+ :return: BunqResponseRaw
8790 """
8891
8992 self ._api_context .ensure_session_active ()
@@ -98,7 +101,8 @@ def _request(self, method, uri_relative, request_bytes, custom_headers):
98101 method ,
99102 self ._get_uri_full (uri_relative ),
100103 data = request_bytes ,
101- headers = all_headers
104+ headers = all_headers ,
105+ proxies = {self ._FIELD_PROXY_HTTPS : self ._api_context .proxy_url }
102106 )
103107
104108 self ._assert_response_success (response )
@@ -111,7 +115,7 @@ def _request(self, method, uri_relative, request_bytes, custom_headers):
111115 response .headers
112116 )
113117
114- return response
118+ return self . _create_bunq_response_raw ( response )
115119
116120 def _get_all_headers (self , method , endpoint , request_bytes , custom_headers ):
117121 """
@@ -184,6 +188,16 @@ def _assert_response_success(self, response):
184188 self ._fetch_error_messages (response )
185189 )
186190
191+ @classmethod
192+ def _create_bunq_response_raw (cls , response ):
193+ """
194+ :type response: requests.Response
195+
196+ :rtype: BunqResponseRaw
197+ """
198+
199+ return BunqResponseRaw (response .content , response .headers )
200+
187201 def _fetch_error_messages (self , response ):
188202 """
189203 :type response: requests.Response
@@ -221,7 +235,7 @@ def put(self, uri_relative, request_bytes, custom_headers):
221235 :type request_bytes: bytes
222236 :type custom_headers: dict[str, str]
223237
224- :rtype: requests.Response
238+ :rtype: BunqResponseRaw
225239 """
226240
227241 return self ._request (
@@ -236,7 +250,7 @@ def get(self, uri_relative, custom_headers):
236250 :type uri_relative: str
237251 :type custom_headers: dict[str, str]
238252
239- :rtype: requests.Response
253+ :rtype: BunqResponseRaw
240254 """
241255
242256 return self ._request (
@@ -251,7 +265,7 @@ def delete(self, uri_relative, custom_headers):
251265 :type uri_relative: str
252266 :type custom_headers: dict[str, str]
253267
254- :rtype: requests.Response
268+ :rtype: BunqResponseRaw
255269 """
256270
257271 return self ._request (
@@ -260,3 +274,67 @@ def delete(self, uri_relative, custom_headers):
260274 self ._BYTES_EMPTY ,
261275 custom_headers
262276 )
277+
278+
279+ class BunqResponseRaw (object ):
280+ """
281+ :type _body_bytes: bytes
282+ :type _headers: dict[str, str]
283+ """
284+
285+ def __init__ (self , body_bytes , headers ):
286+ """
287+ :type body_bytes: bytes
288+ :type headers: dict[str, str]
289+ """
290+
291+ self ._body_bytes = body_bytes
292+ self ._headers = headers
293+
294+ @property
295+ def body_bytes (self ):
296+ """
297+ :rtype: bytes
298+ """
299+
300+ return self ._body_bytes
301+
302+ @property
303+ def headers (self ):
304+ """
305+ :rtype: dict[str, str]
306+ """
307+
308+ return self ._headers
309+
310+
311+ class BunqResponse (object ):
312+ """
313+ :type _value: T
314+ :type _headers: dict[str, str]
315+ """
316+
317+ def __init__ (self , value , headers ):
318+ """
319+ :type value: T
320+ :type headers: dict[str, str]
321+ """
322+
323+ self ._value = value
324+ self ._headers = headers
325+
326+ @property
327+ def value (self ):
328+ """
329+ :rtype: T
330+ """
331+
332+ return self ._value
333+
334+ @property
335+ def headers (self ):
336+ """
337+ :rtype: dict[str, str]
338+ """
339+
340+ return self ._headers
0 commit comments