-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_purchase.py
127 lines (104 loc) · 2.83 KB
/
make_purchase.py
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import os
import requests
import json
import config
apiKey = os.environ["capitalone_api_key"]
accountId = os.environ["accountId"]
accountId2 = os.environ["accountId2"]
accountId3 = os.environ["accountId3"]
url_pur = 'http://api.reimaginebanking.com/accounts/{}/purchases?key={}'.format(accountId3,apiKey)
# purchase = {
# "merchant_id": "57cf75cea73e494d8675ec4a",
# "medium": "balance",
# "purchase_date": "2018-10-27",
# "amount": 1,
# "status": "pending",
# "description": "everything"
# }
# # Create a purchase
# response = requests.post(
# url_pur,
# data=json.dumps(purchase),
# headers={'content-type':'application/json'},
# )
# print(url_pur)
# print(response)
# if response.status_code == 201:
# print('purchase created')
purchases = [{
"merchant_id": "57cf75cea73e494d8675ec49", # More than £100 in 1 transaction at Apple
"medium": "balance",
"purchase_date": "2018-10-27",
"amount": 105,
"status": "pending",
"description": "everything"
},{
"merchant_id": "5ade2542f0cec56abfa40730", # Spend £10 or more at tesco
"medium": "balance",
"purchase_date": "2018-10-27",
"amount": 10.50,
"status": "pending",
"description": "everything"
},{
"merchant_id": "5b06eeeff0cec56abfa40907", # Buy from Amazon.com
"medium": "balance",
"purchase_date": "2018-10-27",
"amount": 24.99,
"status": "pending",
"description": "everything"
},{
"merchant_id": "57cf75cea73e494d8675edd7", # Buy Coffee at Starbucks
"medium": "balance",
"purchase_date": "2018-10-27",
"amount": 10.50,
"status": "pending",
"description": "everything"
},{
"merchant_id": "57cf75cea73e494d8675edad", # Buy lunch from Subway
"medium": "balance",
"purchase_date": "2018-10-27",
"amount": 4.99,
"status": "pending",
"description": "everything"
}]
# {
# "merchant_id": "5555555", # Send money to a friend
# "medium": "balance",
# "purchase_date": "2018-10-27",
# "amount": 10.50,
# "status": "pending",
# "description": "everything"
# },{
# "merchant_id": "5555555", # Transfer to savings account
# "medium": "balance",
# "purchase_date": "2018-10-27",
# "amount": 10.50,
# "status": "pending",
# "description": "everything"
# },
#{
# "merchant_id": "583aadf10fa692b34a9b89f4", # Make purchase in Sheffield
# "medium": "balance",
# "purchase_date": "2018-10-27",
# "amount": 10.50,
# "status": "pending",
# "description": "everything"
# },
# {
# "merchant_id": "5555555", # withdraw some cash
# "medium": "balance",
# "purchase_date": "2018-10-27",
# "amount": 10.50,
# "status": "pending",
# "description": "everything"
# }]
# Create a purchase
for i, pur in enumerate(purchases):
response = requests.post(
url_pur,
data=json.dumps(pur),
headers={'content-type':'application/json'},
)
print(response)
if response.status_code == 201:
print('purchases created')