Trying to store API calls in classes for better reuse.

This commit is contained in:
Norm Rasmussen
2024-06-22 15:40:53 -04:00
parent c17daddc44
commit 4a3b899ab0
3 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,33 @@
import Apikeys
import requests
BASEURL = "https://api.northpass.com/v2/"
#HEADERS = {"accept": "application/json", "X-Api-Key": }
class ApiGlobals:
def __init__(self, headers, payload):
self.headers = headers
self.payload = payload
class ListPeople:
def __init__(self, endpoint, include, page, limit, q):
self.endpoint = endpoint
self.include = include
self.page = page
self.limit = limit
self.q = q
def listpeople():
client = ApiGlobals({"accept":"application/json", "X-Api-Key": Apikeys.SANDATA}, None)
listpeople = ListPeople(f"{BASEURL}people/", None, None, None, None)
response = requests.get(listpeople.endpoint, headers=client.headers)
# client = ApiGlobals({"accept":"application/json", "X-Api-Key": Apikeys.SANDATA}, None)
# print(client.headers)
# listpeople = ListPeople(f"{BASEURL}people/", None, None, None, None)
# print(BASEURL+listpeople.endpoint)
# response = requests.get(listpeople.endpoint, headers=client.headers)
# print(response.status_code)
# print(response.text)
print()