Skip to content

Commit

Permalink
Little cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dnl-blkv committed Aug 15, 2017
1 parent 60440e0 commit 7e62a69
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions bunq/sdk/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,27 +254,6 @@ def session_context(self):

return self._session_context

def to_json(self):
"""
Serializes an ApiContext to JSON string
:rtype: str
"""

return converter.class_to_json(self)

@classmethod
def from_json(cls, data):
"""
Creates an ApiContext instance from JSON string.
:type data: str
:rtype: ApiContext
"""

return converter.json_to_class(ApiContext, data)

def save(self, path=None):
"""
:type path: str
Expand All @@ -288,6 +267,15 @@ def save(self, path=None):
with open(path, self._FILE_MODE_WRITE) as file_:
file_.write(self.to_json())

def to_json(self):
"""
Serializes an ApiContext to JSON string.
:rtype: str
"""

return converter.class_to_json(self)

@classmethod
def restore(cls, path=None):
"""
Expand All @@ -301,6 +289,18 @@ def restore(cls, path=None):

with open(path, cls._FILE_MODE_READ) as file_:
return cls.from_json(file_.read())

@classmethod
def from_json(cls, json_str):
"""
Creates an ApiContext instance from JSON string.
:type json_str: str
:rtype: ApiContext
"""

return converter.json_to_class(ApiContext, json_str)

def __eq__(self, other):
return (self.token == other.token and
Expand Down

0 comments on commit 7e62a69

Please sign in to comment.