-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy patht-50-get-fa-list.py
More file actions
executable file
·46 lines (43 loc) · 1.2 KB
/
t-50-get-fa-list.py
File metadata and controls
executable file
·46 lines (43 loc) · 1.2 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
#!/usr/bin/env vpython3
import json
import datetime
import requests
import sys
from ksefconfig import Config
def main():
cfg = Config(int(sys.argv[1]), sys.argv[2]=='o')
with open(f'{cfg.prefix}-auth.json', 'rt') as fp:
auth = json.loads(fp.read())
dtnow = datetime.datetime.now(datetime.timezone.utc)
dtdiff = datetime.timedelta(days=30)
pageSize = 10
pageOffset = 0
while True:
data = {
'dateRange': {
'dateType': 'Issue',
'from': (dtnow-dtdiff).isoformat(),
'to': dtnow.isoformat(),
},
'subjectType': 'Subject2',
}
resp = requests.post(
cfg.url+f'/invoices/query/metadata?pageOffset={pageOffset}&pageSize={pageSize}',
json=data,
headers={
"Authorization": "Bearer "+auth['accessToken']['token'],
},
timeout=5
)
print(resp)
if resp.status_code != 200:
print(resp.text)
break
data = resp.json()
for inv in data['invoices']:
print(inv)
if data['hasMore']:
pageOffset += 1
else:
break
main()