I'LL NEVER TELL

This commit is contained in:
Brad Ganley 2024-07-27 15:33:49 -05:00
parent 64df1f12a4
commit d4a98a917e

View File

@ -2,6 +2,8 @@ import requests
from dotenv import load_dotenv from dotenv import load_dotenv
import os import os
pageSize = 10 # Just so I don't have to keep changing stuff
load_dotenv() load_dotenv()
def apiGetRequest(api_base, endpoint, params, headers): def apiGetRequest(api_base, endpoint, params, headers):
@ -18,13 +20,45 @@ authToken = os.environ["AUTH_TOKEN"]
clientId = os.environ["CLIENT_ID"] clientId = os.environ["CLIENT_ID"]
endpoint = '/finance/agreementrecap' #endpoint for GET 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 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 params = {'pageSize': pageSize, 'conditions': 'agreementStatus="ACTIVE"', '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(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 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']}") print(f"{item['companyName']} - {item['name']} - {item['agreementStatus']}")
additionsEndpoint = '/finance/agreements/' + str(item['id']) + '/additions' additionsEndpoint = '/finance/agreements/' + str(item['id']) + '/additions'
additions = apiGetRequest(api_base, additionsEndpoint, {'pagesize': 50}, headers) additions = apiGetRequest(api_base, additionsEndpoint, {'pagesize': pageSize}, headers)
for thing in additions: # Yo dawg I heard you like loops for thing in additions: # Yo dawg I heard you like loops
print(' ' + thing['product']['identifier']) print(' ' + thing['product']['identifier'] + ' - $' + str(thing['unitPrice']))
####################### !!! DO NOT DISAPPOINT THE FROG WIZARD !!! #########################
# .-----.
# /7 . (
# / .-. \
# / / \ \
# / ` ) ( )
# / ` ) ). \
# .' _. \_/ . |
# .--. .' _.' )`. |
# ( `---...._.' `---.'_) .. \
# \ `----....___ `. \ |
# `. _ ----- _ `._ )/ |
# `. /" \ /" \`. `._ |
# `. ((O)` ) ((O)` ) `. `._\
# `-- '`---' `---' ) `. `-.
# / ` \ `-.
# .' `. `.
# / ` ` `. `-.
# .--. \ ===._____.======. ` ` `. .___.--` .''''.
# ' .` `-. `. )`. ` ` ` \ .' . ' 8)
# (8 . ` `-.`. ( . ` ` .`\ .' ' ' /
# \ `. ` `-. ) ` . ` ` \ .' ' . ' /
# \ ` `. ` . \`. .--. | ` ) ` .``/ ' // . /
# `. ``. . \ \ .-- `. ( ` /_ ` . / ' . '/ .'
# `. ` \ ` \ \ '-. `-' .' `-. ` . .'/ .'
# \ `.`. ` \ \ ) /`._.` `. ` . .' /
# | `.`. . \ \ (.' `. .' .'
# __/ .. \ \ ` ) \ \.' .. \__
# .-._.-' '" ) .-' `. ( '" `-._.--.
#(_________.-====' / .' /\_)`--..__________..-- `====-. _________)
#####################################################################################