Compare commits

..

No commits in common. "2cfafc0c2ebdba01e49b1ab1240e69c918fd2118" and "c76a92fe8299b40d976dd21f71730755686b8936" have entirely different histories.

2 changed files with 6 additions and 10 deletions

View File

@ -1,3 +0,0 @@
AUTH_TOKEN=
CLIENT_ID=
API_BASE=https://portal.gotocompu.com/v4_6_release/apis/3.0

View File

@ -11,18 +11,17 @@ def apiGetRequest(api_base, endpoint, params, headers):
if resp.status_code == 200:
return resp.json()
api_base = os.environ["API_BASE"]
apiBase = os.environ["API_BASE"]
authToken = os.environ["AUTH_TOKEN"]
clientId = os.environ["CLIENT_ID"]
endpoint = '/finance/agreementrecap' #endpoint for GET
headers = {'Authorization': authToken, 'clientId': clientId} # DO NOT fill this out and then commit it to the publicly-viewable git repository, please
params = {'pageSize': 50, 'conditions': 'agreementStatus!="CANCEL"', 'fields': 'id,companyName,name,lastInvoiceAmount,nextInvoiceAmount,agreementStatus'} # API call params--prepare to cry if your url encoding is sub-par
data = apiGetRequest(api_base, endpoint, params, headers) #Put it all together and whadya get
data = apiGetRequest(apiBase, endpoint, params, headers) #Put it all together and whadya get
for item in data: #This is just iterating through whatever comes back and barfing the data in a readable way
print(f"{item['companyName']} - {item['name']} - {item['agreementStatus']}")
additionsEndpoint = '/finance/agreements/' + str(item['id']) + '/additions'
additions = apiGetRequest(api_base, additionsEndpoint, {'pagesize': 50}, headers)
for thing in additions:
print(' ' + thing['product']['identifier'])
print(f"{item['companyName']} - {item['name']} \n - {item['agreementStatus']}")
# to do: Make a second function to call agreement additions from returned items. Should be so easy that it's actually kind of stupid that I'm writing this instead of that right now