Skip to content

Commit 4907492

Browse files
author
Kevin Hellemun
committed
Merge branch 'release/0.12.2'
2 parents 226bf71 + 4140ec1 commit 4907492

File tree

7 files changed

+564
-308
lines changed

7 files changed

+564
-308
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Steps to reproduce:
2+
1.
3+
4+
## What should happen:
5+
1.
6+
7+
## What happens:
8+
1.
9+
10+
## Logs
11+
- Logs
12+
13+
## Extra info:
14+
- Tested on

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.12.0
1+
0.12.2

bunq/sdk/client.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ class ApiClient(object):
1515
:type _api_context: bunq.sdk.context.ApiContext
1616
"""
1717

18+
# Endpoints not requiring active session for the request to succeed.
19+
_URL_DEVICE_SERVER = 'device-server'
20+
_URI_INSTALLATION = 'installation'
21+
_URI_SESSION_SERVER = 'session-server'
22+
_URIS_NOT_REQUIRING_ACTIVE_SESSION = [
23+
_URI_INSTALLATION,
24+
_URI_SESSION_SERVER,
25+
_URL_DEVICE_SERVER,
26+
]
27+
1828
# HTTPS type of proxy, the only used at bunq
1929
_FIELD_PROXY_HTTPS = 'https'
2030

@@ -31,7 +41,7 @@ class ApiClient(object):
3141
HEADER_AUTHENTICATION = 'X-Bunq-Client-Authentication'
3242

3343
# Default header values
34-
_USER_AGENT_BUNQ = 'bunq-sdk-python/0.12.0'
44+
_USER_AGENT_BUNQ = 'bunq-sdk-python/0.12.2'
3545
_GEOLOCATION_ZERO = '0 0 0 0 NL'
3646
_LANGUAGE_EN_US = 'en_US'
3747
_REGION_NL_NL = 'nl_NL'
@@ -93,7 +103,9 @@ def _request(self, method, uri_relative, request_bytes, params,
93103

94104
uri_relative_with_params = self._append_params_to_uri(uri_relative,
95105
params)
96-
self._api_context.ensure_session_active()
106+
if uri_relative not in self._URIS_NOT_REQUIRING_ACTIVE_SESSION:
107+
self._api_context.ensure_session_active()
108+
97109
all_headers = self._get_all_headers(
98110
method,
99111
uri_relative_with_params,

bunq/sdk/context.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,28 @@ def _get_session_timeout_seconds(cls, session_server):
166166
return session_server.user_person.session_timeout
167167

168168
def ensure_session_active(self):
169+
"""
170+
Resets the session if it has expired.
171+
"""
172+
173+
if not self.is_session_active():
174+
self.reset_session()
175+
176+
def is_session_active(self):
177+
"""
178+
:rtype: bool
179+
"""
180+
169181
if self.session_context is None:
170-
return
182+
return False
171183

172184
time_now = datetime.datetime.now()
173185
time_to_expiry = self.session_context.expiry_time - time_now
174186
time_to_expiry_minimum = datetime.timedelta(
175187
seconds=self._TIME_TO_SESSION_EXPIRY_MINIMUM_SECONDS
176188
)
177189

178-
if time_to_expiry < time_to_expiry_minimum:
179-
self.reset_session()
190+
return time_to_expiry > time_to_expiry_minimum
180191

181192
def reset_session(self):
182193
"""

0 commit comments

Comments
 (0)