Luminate Mexico templates for spanish and english courses. Todos. New script for bulk adding of people.
This commit is contained in:
40
Scripts/API_Tests/bulk_add_ppl_from_csv.py
Normal file
40
Scripts/API_Tests/bulk_add_ppl_from_csv.py
Normal 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()
|
||||
Reference in New Issue
Block a user