-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added getting requested payments info and cancel/remind a payment
Showing
10 changed files
with
280 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,7 @@ media | |
|
||
|
||
### Other ### | ||
tests.py | ||
venmo_api/test.py | ||
test*.py | ||
|
||
### Linux ### | ||
*~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from enum import Enum | ||
|
||
from venmo_api import string_to_timestamp, User | ||
from venmo_api import JSONSchema | ||
|
||
|
||
class Payment(object): | ||
|
||
def __init__(self, id_, actor, target, action, amount, audience, date_created, date_reminded, date_completed, | ||
note, status): | ||
""" | ||
Create a Payment object | ||
:param id_: | ||
:param actor: | ||
:param target: | ||
:param action: | ||
:param amount: | ||
:param audience: | ||
:param date_created: | ||
:param date_reminded: | ||
:param date_completed: | ||
:param note: | ||
:param status: | ||
""" | ||
super().__init__() | ||
self.id = id_ | ||
self.actor = actor | ||
self.target = target | ||
self.action = action | ||
self.amount = amount | ||
self.audience = audience | ||
self.date_created = date_created | ||
self.date_reminded = date_reminded | ||
self.date_completed = date_completed | ||
self.note = note | ||
self.status = status | ||
|
||
@classmethod | ||
def from_json(cls, json): | ||
""" | ||
init a new Payment form JSON | ||
:param json: | ||
:return: | ||
""" | ||
if not json: | ||
return | ||
|
||
parser = JSONSchema.payment(json) | ||
|
||
return cls( | ||
id_=parser.get_id(), | ||
actor=User.from_json(parser.get_actor()), | ||
target=User.from_json(parser.get_target()), | ||
action=parser.get_action(), | ||
amount=parser.get_amount(), | ||
audience=parser.get_amount(), | ||
date_created=string_to_timestamp(parser.get_date_created()), | ||
date_reminded=string_to_timestamp(parser.get_date_reminded()), | ||
date_completed=string_to_timestamp(parser.get_date_completed()), | ||
note=parser.get_note(), | ||
status=PaymentStatus(parser.get_status()) | ||
) | ||
|
||
def __str__(self) -> str: | ||
return '%s(%s)' % ( | ||
type(self).__name__, | ||
', '.join('%s=%s' % item for item in vars(self).items()) | ||
) | ||
|
||
|
||
class PaymentStatus(Enum): | ||
SETTLED = 'settled' | ||
CANCELLED = 'cancelled' | ||
PENDING = 'pending' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters