2024-06-22 15:40:53 -04:00
|
|
|
import Apikeys
|
|
|
|
|
import requests
|
|
|
|
|
|
2024-06-23 18:41:26 -04:00
|
|
|
"""
|
|
|
|
|
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?
|
|
|
|
|
"""
|
2024-06-22 15:40:53 -04:00
|
|
|
|
|
|
|
|
class ApiGlobals:
|
2024-06-23 18:41:26 -04:00
|
|
|
apikey = ""
|
|
|
|
|
headers = {"accept": "application/json", "X-Api-Key": apikey }
|
|
|
|
|
baseurl = "https://api.northpass.com/v2/"
|
|
|
|
|
|
|
|
|
|
def __init__(self, apikey):
|
|
|
|
|
self.apikey = apikey
|
2024-06-22 15:40:53 -04:00
|
|
|
|
|
|
|
|
class ListPeople:
|
2024-06-23 18:41:26 -04:00
|
|
|
endpoint = "people/"
|
|
|
|
|
print(endpoint)
|
|
|
|
|
|
|
|
|
|
def call_endpoint():
|
|
|
|
|
response = requests.get(listpeople.endpoint, headers=client.headers)
|
|
|
|
|
|
|
|
|
|
# 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}
|
2024-06-22 15:40:53 -04:00
|
|
|
|
|
|
|
|
def listpeople():
|
2024-06-23 18:41:26 -04:00
|
|
|
for item, val in listpeople.list_dict.items():
|
|
|
|
|
if val is not None:
|
|
|
|
|
print(val)
|
|
|
|
|
else:
|
|
|
|
|
print("nothing exists")
|
2024-06-22 15:40:53 -04:00
|
|
|
response = requests.get(listpeople.endpoint, headers=client.headers)
|
|
|
|
|
|
2024-06-23 18:41:26 -04:00
|
|
|
# class PostPeopleCustomProps:
|
|
|
|
|
# endpoint = "properties/people/bulk"
|
|
|
|
|
# payload = { "data": [
|
|
|
|
|
# {
|
|
|
|
|
# "attributes": { "properties": { newKey: NewValue } },
|
|
|
|
|
# "id": uuid,
|
|
|
|
|
# "type": "person_properties"
|
|
|
|
|
# }
|
|
|
|
|
# ] }
|
|
|
|
|
|
|
|
|
|
class PostBulkInvite:
|
|
|
|
|
endpoint = "bulk/people"
|
2024-06-22 15:40:53 -04:00
|
|
|
|
2024-06-23 18:41:26 -04:00
|
|
|
setup = ApiGlobals(Apikeys.SANDATA)
|
|
|
|
|
p = ListPeople()
|