-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtdData.py
33 lines (26 loc) · 997 Bytes
/
tdData.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
# install the requests package using 'python -m pip install requests'
import requests
import json
def get_td_data(customer):
configFile = open("config.txt", "r")
response = requests.get(
'https://api.td-davinci.com/api/customers/' + customer + '/transactions',
headers={'Authorization': json.load(configFile)['td']},
json={'continuationToken': ''}
)
response_data = response.json()
return response_data["result"]
def filtered_resp(customer):
responses = get_td_data(customer)
responses_list = []
data = ["locationLatitude", "locationLongitude", "currencyAmount", "merchantName", "categoryTags", "locationStreet", "originationDateTime"]
for resp in responses:
temp = []
try:
for d in data:
temp.append(resp[d])
responses_list.append(temp)
except:
pass
return responses_list
# responses list should be [ [locationlat, locationlong, amount], []... ]