Skip to content

Commit

Permalink
Merge pull request #80 from bunq/refresh_user_context_bunq/sdk_python#79
Browse files Browse the repository at this point in the history
Added method to refresh user context data. (#79)
  • Loading branch information
OGKevin authored Apr 6, 2018
2 parents 414a72a + 3688d86 commit e50567a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions bunq/sdk/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,15 @@ def __init__(self, user_id):
self._user_company = None
self._primary_monetary_account = None

user_object = endpoint.User.list().value[0].get_referenced_object()
self._set_user(user_object)
self._set_user(self.__get_user_object())

@staticmethod
def __get_user_object():
"""
:rtype: core.BunqModel
"""

return endpoint.User.list().value[0].get_referenced_object()

def _set_user(self, user):
if isinstance(user, endpoint.UserPerson):
Expand Down Expand Up @@ -478,6 +485,13 @@ def is_both_user_type_set(self):

return self._user_company is not None and self._user_person is not None

def refresh_user_context(self):
"""
"""

self._set_user(self.__get_user_object())
self.init_main_monetary_account()

@property
def user_company(self):
"""
Expand Down

0 comments on commit e50567a

Please sign in to comment.