-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlistinvoice.py
executable file
·51 lines (29 loc) · 1.05 KB
/
listinvoice.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
#!/usr/bin/env python
import requests
import json
import hackerspace_utils as hu
authbag = hu.get_auth_bag()
url = "https://sandbox-quickbooks.api.intuit.com/v3/company/123146047051614/query"
querystring = {"minorversion":"14"}
payload="select * from invoice startposition 1 maxresults 5"
Token = authbag['token'];
headers = {
'Accept': "application/json",
'Content-Type': "application/text",
'Authorization': "Bearer "+Token,
'Cache-Control': "no-cache",
}
response = requests.request("POST", url, data=payload, headers=headers, params=querystring)
resj = json.loads(response.text);
qresult = resj['QueryResponse']
invoices = qresult['Invoice']
# import pdb; pdb.set_trace()
distillate = { inv['Id']:
{
'custid':inv['CustomerRef']['value'],
'custname':inv['CustomerRef']['name'],
'TxnDate':inv['TxnDate'],
'Amount':inv['TotalAmt'],
}
for inv in invoices }
print (json.dumps(distillate,sort_keys=True,indent=4))