-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathtransaction.py
More file actions
72 lines (54 loc) · 2.36 KB
/
transaction.py
File metadata and controls
72 lines (54 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
__author__ = 'gsibble'
from amount import CoinbaseAmount
from contact import CoinbaseContact
class CoinbaseTransaction(object):
def __init__(self, transaction):
self.data = transaction
self.transaction_id = transaction['id']
self.created_at = transaction.get('created_at', None)
self.notes = transaction.get('notes', '')
if 'amount' in transaction:
transaction_amount = transaction['amount']['amount']
transaction_currency = transaction['amount']['currency']
self.amount = CoinbaseAmount(transaction_amount, transaction_currency)
else:
self.amount = None
self.status = transaction.get('status', None)
self.request = transaction.get('request', None)
#Sender Information
if 'sender' in transaction:
sender_id = transaction['sender'].get('id', None)
sender_name = transaction['sender'].get('name', None)
sender_email = transaction['sender'].get('email', None)
self.sender = CoinbaseContact(contact_id=sender_id,
name=sender_name,
email=sender_email)
else:
#TODO: Not sure what key would go here
pass
#Recipient Info
if 'recipient' in transaction:
recipient_id = transaction['recipient'].get('id', None)
recipient_name = transaction['recipient'].get('name', None)
recipient_email = transaction['recipient'].get('email', None)
self.recipient = CoinbaseContact(contact_id=recipient_id,
name=recipient_name,
email=recipient_email)
self.recipient_address = None
self.recipient_type = 'CoinBase'
elif 'recipient_address' in transaction:
self.recipient = None
self.recipient_address = transaction['recipient_address']
self.recipient_type = 'Bitcoin'
def refresh(self):
pass
#TODO: Refresh the transaction
def cancel(self):
pass
#TODO: Cancel the transaction if possible
def complete(self):
pass
#TODO: Approve the transaction if possible
def resend(self):
pass
#TODO: Resend the transaction email if possible