Skip to content

Commit

Permalink
Added amount to transactions; Added phone number to your profile (#3)
Browse files Browse the repository at this point in the history
* added amount to transaction and to transaction json parser

* added phone number to user and profile. Notice that it is only valid for your profile. For any other user on Venmo, it will be None.

* fixed a typo in json_schema

Co-authored-by: Dylan Russell <>
Co-authored-by: Mark Mohades <mmohades@hotmail.com>
  • Loading branch information
dylanrussellmd and mmohades committed May 29, 2020
1 parent 01c66c7 commit 2cf536a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
10 changes: 9 additions & 1 deletion venmo_api/models/json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def get_target(self):
def get_status(self):
return self.payment.get(payment_json_format['status'])

def get_amount(self):
return self.payment.get(payment_json_format['amount'])

transaction_json_format = {
"story_id": "id",
Expand All @@ -88,7 +90,8 @@ def get_status(self):
"target": "target",
"actor": "actor",
"note": "note",
"type": "action"
'type': 'action',
'amount': 'amount'
}


Expand Down Expand Up @@ -122,6 +125,9 @@ def get_last_name(self):
def get_full_name(self):
return self.json.get(self.parser.get('full_name'))

def get_phone(self):
return self.json.get(self.parser.get('phone'))

def get_picture_url(self):
return self.json.get(self.parser.get('picture_url'))

Expand All @@ -148,6 +154,7 @@ def get_is_active(self):
'first_name': 'first_name',
'last_name': 'last_name',
'full_name': 'display_name',
'phone': 'phone',
'picture_url': 'profile_picture_url',
'about': 'about',
'date_created': 'date_joined',
Expand All @@ -161,6 +168,7 @@ def get_is_active(self):
'first_name': 'firstname',
'last_name': 'lastname',
'full_name': 'name',
'phone': 'phone',
'picture_url': 'picture',
'about': 'about',
'date_created': 'date_created',
Expand Down
6 changes: 4 additions & 2 deletions venmo_api/models/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class Transaction(object):

def __init__(self, story_id, payment_id, date_completed, date_created,
date_updated, payment_type, audience, status,
date_updated, payment_type, amount, audience, status,
note, device_used, actor, target):

super().__init__()
Expand All @@ -21,6 +21,7 @@ def __init__(self, story_id, payment_id, date_completed, date_created,
self.date_updated = date_updated

self.payment_type = payment_type
self.amount = amount
self.audience = audience
self.status = status

Expand Down Expand Up @@ -62,6 +63,7 @@ def from_json(cls, json):
date_created=date_created,
date_updated=date_updated,
payment_type=parser.get_type(),
amount=parser.get_amount(),
audience=parser.get_audience(),
note=parser.get_story_note(),
status=parser.get_status(),
Expand All @@ -73,7 +75,7 @@ def __str__(self):

return f'story_id: {self.id}, payment_id: {self.payment_id}, date_completed: {self.date_completed},' \
f'date_created: {self.date_created}, date_updated: {self.date_updated},' \
f' payment_type: {self.payment_type},' \
f'payment_type: {self.payment_type}, amount: {self.amount},' \
f'audience: {self.audience}, status: {self.status}, note: {self.note}, device_used: {self.device_used},\n' \
f'actor_user: {self.actor},\n' \
f'target_user: {self.target}\n'
Expand Down
9 changes: 6 additions & 3 deletions venmo_api/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

class User(object):

def __init__(self, user_id, username, first_name, last_name, display_name, profile_picture_url,
about, date_joined, is_group, is_active):
def __init__(self, user_id, username, first_name, last_name, display_name, phone,
profile_picture_url, about, date_joined, is_group, is_active):
"""
Initialize a new user
:param user_id:
:param username:
:param first_name:
:param last_name:
:param display_name:
:param phone:
:param profile_picture_url:
:param about:
:param date_joined:
Expand All @@ -27,6 +28,7 @@ def __init__(self, user_id, username, first_name, last_name, display_name, profi
self.first_name = first_name
self.last_name = last_name
self.display_name = display_name
self.phone = phone
self.profile_picture_url = profile_picture_url
self.about = about
self.date_joined = date_joined
Expand All @@ -53,6 +55,7 @@ def from_json(cls, json, is_profile=False):
first_name=parser.get_first_name(),
last_name=parser.get_last_name(),
display_name=parser.get_full_name(),
phone=parser.get_phone(),
profile_picture_url=parser.get_picture_url(),
about=parser.get_about(),
date_joined=date_joined_timestamp,
Expand All @@ -61,5 +64,5 @@ def from_json(cls, json, is_profile=False):

def __str__(self):
return f'id: {self.id}, username: {self.username}, firstname: {self.first_name}, lastname: {self.last_name}'\
f' display_name: {self.display_name}, picture: {self.profile_picture_url}, about: {self.about},'\
f' display_name: {self.display_name}, phone: {self.phone}, picture: {self.profile_picture_url}, about: {self.about},'\
f' joined: {self.date_joined}, is_group: {self.is_group}, is_active: {self.is_active}'

0 comments on commit 2cf536a

Please sign in to comment.