Added some notes for how I want to construct this. Not sure if this is useful.
This commit is contained in:
@ -1,33 +1,65 @@
|
||||
import Apikeys
|
||||
import requests
|
||||
|
||||
BASEURL = "https://api.northpass.com/v2/"
|
||||
#HEADERS = {"accept": "application/json", "X-Api-Key": }
|
||||
"""
|
||||
I want to construct this with the goal of a TUI/GUI app that lets you string together multiple calls.
|
||||
For instance, someone should be able to input that they want to add everyone from a CSV using their email
|
||||
and then add their properties. Assuming everything is in a CSV the data flow for this would be:
|
||||
1. Import CSV with email value into app
|
||||
2. Bulk Invite using email
|
||||
3. Get each person with a filter for email
|
||||
4. Bulk Post custom learner prop with value
|
||||
|
||||
So how can I reuse something over and over? If I need to list people, all I need is the Api key & Endpoint.
|
||||
Should the app instantiate a Globals class with the key, headers, and baseurl, and then you call the specific
|
||||
function?
|
||||
"""
|
||||
|
||||
class ApiGlobals:
|
||||
def __init__(self, headers, payload):
|
||||
self.headers = headers
|
||||
self.payload = payload
|
||||
apikey = ""
|
||||
headers = {"accept": "application/json", "X-Api-Key": apikey }
|
||||
baseurl = "https://api.northpass.com/v2/"
|
||||
|
||||
def __init__(self, apikey):
|
||||
self.apikey = apikey
|
||||
|
||||
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
|
||||
endpoint = "people/"
|
||||
print(endpoint)
|
||||
|
||||
def listpeople():
|
||||
client = ApiGlobals({"accept":"application/json", "X-Api-Key": Apikeys.SANDATA}, None)
|
||||
listpeople = ListPeople(f"{BASEURL}people/", None, None, None, None)
|
||||
def call_endpoint():
|
||||
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)
|
||||
# def __init__(self, endpoint, include, page, limit, q):
|
||||
# self.endpoint = endpoint
|
||||
# self.include = include
|
||||
# self.page = page
|
||||
# self.limit = limit
|
||||
# self.q = q
|
||||
#
|
||||
# self.list_dict = {"endpoint": self.endpoint, "include": self.include, "page":self.page,
|
||||
# "limit":self.limit, "q":self.q}
|
||||
|
||||
print()
|
||||
def listpeople():
|
||||
for item, val in listpeople.list_dict.items():
|
||||
if val is not None:
|
||||
print(val)
|
||||
else:
|
||||
print("nothing exists")
|
||||
response = requests.get(listpeople.endpoint, headers=client.headers)
|
||||
|
||||
# class PostPeopleCustomProps:
|
||||
# endpoint = "properties/people/bulk"
|
||||
# payload = { "data": [
|
||||
# {
|
||||
# "attributes": { "properties": { newKey: NewValue } },
|
||||
# "id": uuid,
|
||||
# "type": "person_properties"
|
||||
# }
|
||||
# ] }
|
||||
|
||||
class PostBulkInvite:
|
||||
endpoint = "bulk/people"
|
||||
|
||||
setup = ApiGlobals(Apikeys.SANDATA)
|
||||
p = ListPeople()
|
||||
|
||||
Reference in New Issue
Block a user