From 2e7f0553ceb12c7153638f4a7e12e71ef7dd6255 Mon Sep 17 00:00:00 2001 From: Brad Ganley Date: Fri, 26 Jul 2024 20:18:00 -0500 Subject: [PATCH] Did all of the things that currently exist in a state of having been did --- reportguy.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 reportguy.py diff --git a/reportguy.py b/reportguy.py new file mode 100644 index 0000000..420aa8a --- /dev/null +++ b/reportguy.py @@ -0,0 +1,19 @@ +import requests + +def apiGetRequest(api_base, endpoint, params, headers): + url = api_base + endpoint + resp = requests.get(url, params=params, headers=headers) + + if resp.status_code == 200: + return resp.json() + +api_base = 'https://portal.gotocompu.com/v4_6_release/apis/3.0' # Ctype on-prem api url +endpoint = '/finance/agreementrecap' #endpoint for GET +headers = {'Authorization': '', '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 +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']} \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 +