Luminate Mexico templates for spanish and english courses. Todos. New script for bulk adding of people.

This commit is contained in:
Norm Rasmussen
2024-05-31 15:46:04 -04:00
parent ec2ef3a808
commit bf13bb7131
7 changed files with 75 additions and 12 deletions

View File

@ -0,0 +1,40 @@
import requests
import json
import pprint
import csv
import Apikeys
pp = pprint.PrettyPrinter(indent=4)
APIKEY = Apikeys.ZENJOB
HEADERS = {
"accept": "application/json",
"X-Api-Key": APIKEY,
}
BASEURL = "https://api.northpass.com/v2/"
def bulk_invite_ppl():
"""
Bulk endpoint which invites new people and adds them to a group via this structure:
{
"email": "me@mac.com"
"groups": "GroupA"
}
"""
payload_1 = []
with open ("/Users/normrasmussen/Downloads/Zenjob_empoloyees.csv", "r") as csvfile:
for person in csvfile:
person = person[:-1]
miniload = {
"email": person,
"groups": "Internal Zenjob Testing"
}
payload_1.append(miniload)
payload = payload = { "data": { "attributes": { "people": payload_1 } } }
print(payload)
url = f"{BASEURL}bulk/people"
response = requests.post(url, headers=HEADERS, json=payload)
print(f"Completed. Status code is {response.status_code}")
if __name__ == "__main__":
bulk_invite_ppl()