diff --git a/reportguy.py b/reportguy.py index 01dcf8c..7e06d10 100644 --- a/reportguy.py +++ b/reportguy.py @@ -10,6 +10,8 @@ def apiGetRequest(api_base, endpoint, params, headers): if resp.status_code == 200: return resp.json() + else: + resp.raise_for_status() api_base = os.environ["API_BASE"] authToken = os.environ["AUTH_TOKEN"] @@ -23,6 +25,6 @@ data = apiGetRequest(api_base, endpoint, params, headers) #Put it all together a 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: + additions = apiGetRequest(api_base, additionsEndpoint, {'pagesize': 50}, headers) + for thing in additions: # Yo dawg I heard you like loops print(' ' + thing['product']['identifier'])