@@ -19,6 +19,9 @@ class ApiClient(object):
19
19
:type _api_context: context.ApiContext
20
20
"""
21
21
22
+ # HTTPS type of proxy, the only used at bunq
23
+ _FIELD_PROXY_HTTPS = 'https'
24
+
22
25
# Header constants
23
26
HEADER_ATTACHMENT_DESCRIPTION = 'X-Bunq-Attachment-Description'
24
27
HEADER_CONTENT_TYPE = 'Content-Type'
@@ -32,7 +35,7 @@ class ApiClient(object):
32
35
HEADER_AUTHENTICATION = 'X-Bunq-Client-Authentication'
33
36
34
37
# Default header values
35
- _USER_AGENT_BUNQ = 'bunq-sdk-python/0.9 '
38
+ _USER_AGENT_BUNQ = 'bunq-sdk-python/0.10.0 '
36
39
_GEOLOCATION_ZERO = '0 0 0 0 NL'
37
40
_LANGUAGE_EN_US = 'en_US'
38
41
_REGION_NL_NL = 'nl_NL'
@@ -66,7 +69,7 @@ def post(self, uri_relative, request_bytes, custom_headers):
66
69
:type request_bytes: bytes
67
70
:type custom_headers: dict[str, str]
68
71
69
- :return: requests.Response
72
+ :return: BunqResponseRaw
70
73
"""
71
74
72
75
return self ._request (
@@ -83,7 +86,7 @@ def _request(self, method, uri_relative, request_bytes, custom_headers):
83
86
:type request_bytes: bytes
84
87
:type custom_headers: dict[str, str]
85
88
86
- :return: requests.Response
89
+ :return: BunqResponseRaw
87
90
"""
88
91
89
92
self ._api_context .ensure_session_active ()
@@ -98,7 +101,8 @@ def _request(self, method, uri_relative, request_bytes, custom_headers):
98
101
method ,
99
102
self ._get_uri_full (uri_relative ),
100
103
data = request_bytes ,
101
- headers = all_headers
104
+ headers = all_headers ,
105
+ proxies = {self ._FIELD_PROXY_HTTPS : self ._api_context .proxy_url }
102
106
)
103
107
104
108
self ._assert_response_success (response )
@@ -111,7 +115,7 @@ def _request(self, method, uri_relative, request_bytes, custom_headers):
111
115
response .headers
112
116
)
113
117
114
- return response
118
+ return self . _create_bunq_response_raw ( response )
115
119
116
120
def _get_all_headers (self , method , endpoint , request_bytes , custom_headers ):
117
121
"""
@@ -184,6 +188,16 @@ def _assert_response_success(self, response):
184
188
self ._fetch_error_messages (response )
185
189
)
186
190
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
+
187
201
def _fetch_error_messages (self , response ):
188
202
"""
189
203
:type response: requests.Response
@@ -221,7 +235,7 @@ def put(self, uri_relative, request_bytes, custom_headers):
221
235
:type request_bytes: bytes
222
236
:type custom_headers: dict[str, str]
223
237
224
- :rtype: requests.Response
238
+ :rtype: BunqResponseRaw
225
239
"""
226
240
227
241
return self ._request (
@@ -236,7 +250,7 @@ def get(self, uri_relative, custom_headers):
236
250
:type uri_relative: str
237
251
:type custom_headers: dict[str, str]
238
252
239
- :rtype: requests.Response
253
+ :rtype: BunqResponseRaw
240
254
"""
241
255
242
256
return self ._request (
@@ -251,7 +265,7 @@ def delete(self, uri_relative, custom_headers):
251
265
:type uri_relative: str
252
266
:type custom_headers: dict[str, str]
253
267
254
- :rtype: requests.Response
268
+ :rtype: BunqResponseRaw
255
269
"""
256
270
257
271
return self ._request (
@@ -260,3 +274,67 @@ def delete(self, uri_relative, custom_headers):
260
274
self ._BYTES_EMPTY ,
261
275
custom_headers
262
276
)
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