-
Notifications
You must be signed in to change notification settings - Fork 0
/
remove_all_transactions.py
85 lines (56 loc) · 1.93 KB
/
remove_all_transactions.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
### DOES NOT WORK YET!
import os
import requests
import json
import config
apiKey = os.environ["capitalone_api_key"]
accountId = os.environ["accountId"]
# call current transactions
url_pur_get = 'http://api.reimaginebanking.com/accounts/{}/purchases?key={}'.format(accountId,apiKey)
url_trans_get = 'http://api.reimaginebanking.com/accounts/{}/transfers?key={}'.format(accountId,apiKey)
url_with_get = 'http://api.reimaginebanking.com/accounts/{}/withdrawals?key={}'.format(accountId,apiKey)
# Get list of purchase IDs
purchases = requests.get(url_pur_get)
transfers = requests.get(url_trans_get)
withdrawals = requests.get(url_with_get)
pur_info = json.loads(purchases.text)
# print(pur_info)
trans_info = json.loads(transfers.text)
# print(trans_info)
# with_info = json.loads(withdrawals.text)
# print(with_info)
for i, item in enumerate(pur_info):
pur_id = item["_id"]
pur_id_send = [{
"_id": pur_id,
"code": 0,
"message": "string",
"fields": "string"
}]
url_pur_del = 'http://api.reimaginebanking.com/accounts/{}/purchases?key={}'.format(pur_id_send,apiKey)
response = requests.delete(url_pur_del,
data=json.dumps(pur_id_send),
headers={'content-type':'application/json'})
print(pur_id)
print(response)
if response.status_code == 201:
print('purchases created')
for i, item in enumerate(pur_info):
pur_id = item["_id"]
pur_id_send = [{
"_id": pur_id,
"code": 0,
"message": "string",
"fields": "string"
}]
url_trans_del = 'http://api.reimaginebanking.com/accounts/{}/transfers?key={}'.format(_id,apiKey)
response = requests.delete(url_trans_del,
data=json.dumps(pur_id_send),
headers={'content-type':'application/json'})
print(pur_id)
print(response)
if response.status_code == 201:
print('purchases created'
# for i, item in enumerate(pur_info):
# _id = item["_id"]
# url_with_del = 'http://api.reimaginebanking.com/accounts/{}/withdrawals?key={}'.format(_id,apiKey)