Skip to content

Commit

Permalink
updated to_json method
Browse files Browse the repository at this point in the history
  • Loading branch information
mmohades committed Jan 8, 2021
1 parent a80660f commit e96d84e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions venmo_api/models/base_model.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class BaseModel(object):
def __init__(self):
self.__json = None
self._json = None

def __str__(self):
return f"{type(self).__name__}:" \
f" ({', '.join('%s=%s' % item for item in vars(self).items() if not item[0].startswith('_'))})"

def to_json(self):
if self.__json:
return self.__json
def to_json(self, original=True):
if self._json and original:
return self._json

return dict(filter(lambda x: not x[0].startswith('_'), vars(self).items()))
2 changes: 1 addition & 1 deletion venmo_api/models/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, id_, actor, target, action, amount, audience, date_created, d
self.date_completed = date_completed
self.note = note
self.status = status
self.__json = json
self._json = json

@classmethod
def from_json(cls, json):
Expand Down
2 changes: 1 addition & 1 deletion venmo_api/models/payment_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, pid: str, p_role: str, p_name: str, p_type: str, json=None):
self.role = PaymentRole(p_role)
self.name = p_name
self.type = payment_type.get(p_type)
self.__json = json
self._json = json

@classmethod
def from_json(cls, json: Dict):
Expand Down
2 changes: 1 addition & 1 deletion venmo_api/models/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, story_id, payment_id, date_completed, date_created,

self.actor = actor
self.target = target
self.__json = json
self._json = json

@classmethod
def from_json(cls, json):
Expand Down
2 changes: 1 addition & 1 deletion venmo_api/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, user_id, username, first_name, last_name, display_name, phone
self.date_joined = date_joined
self.is_group = is_group
self.is_active = is_active
self.__json = json
self._json = json

@classmethod
def from_json(cls, json, is_profile=False):
Expand Down

0 comments on commit e96d84e

Please sign in to comment.