Added two new talkspace scripts
This commit is contained in:
@ -9,3 +9,4 @@ recast = "9LISLpq7Ebqot3Xrggn5twKWZ"
|
||||
mizuno = "stXNF84HWL8aCGeRjHEo2rJ1U"
|
||||
sps = "VNDXh8K4tLYJ-Nvp78bo6w"
|
||||
anthology = "BwDUDT3mM6xzubFOgrPZNfL53"
|
||||
talkspace_1099 = "jpfQoIc2i5S6iq4saFjBOEkbt"
|
||||
|
||||
Binary file not shown.
41
Scripts/API_Tests/deactivate_person.py
Normal file
41
Scripts/API_Tests/deactivate_person.py
Normal file
@ -0,0 +1,41 @@
|
||||
import requests
|
||||
import Apikeys
|
||||
import csv
|
||||
|
||||
apiKey = Apikeys.talkspace_1099
|
||||
baseUrlemail = "https://api.northpass.com/v2/people?filter[email][eq]="
|
||||
import_list = "/Users/normrasmussen/Downloads/Deactivate Providers - 5.1.23 - Sheet1.csv"
|
||||
|
||||
def getfromEmail(baseUrlemail, apiKey, import_list):
|
||||
with open(import_list, newline='') as csvfile:
|
||||
file = csv.reader(csvfile, delimiter=' ')
|
||||
for email in file:
|
||||
email = str(email).strip("['']")
|
||||
url = baseUrlemail + f"{email}"
|
||||
headers = {
|
||||
"accept": "*/*",
|
||||
"x-api-key": apiKey,
|
||||
"content-type": "application/json",
|
||||
}
|
||||
response = requests.get(url, headers=headers)
|
||||
if response.status_code == 200:
|
||||
response = response.json()
|
||||
for data in response["data"]:
|
||||
uuid = data["id"]
|
||||
deactivate(email, uuid, apiKey)
|
||||
else:
|
||||
print("Another Error!")
|
||||
|
||||
|
||||
def deactivate(email, uuid, apiKey):
|
||||
print(f"Deactivating user {email} with uuid {uuid}.")
|
||||
url = f"https://api.northpass.com/v2/people/{uuid}/deactivations"
|
||||
headers = {"accept": "application/json","x-api-key": apiKey}
|
||||
response = requests.post(url, headers=headers)
|
||||
if response.status_code == 404 or response.status_code == 403:
|
||||
print(f"Error {response.status_code} with uuid {uuid}")
|
||||
else:
|
||||
print("Successfully deactivated!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
getfromEmail(baseUrlemail, apiKey, import_list)
|
||||
61
Scripts/API_Tests/from_email_to_multiprop.py
Normal file
61
Scripts/API_Tests/from_email_to_multiprop.py
Normal file
@ -0,0 +1,61 @@
|
||||
import requests
|
||||
import Apikeys
|
||||
import csv
|
||||
|
||||
apikey = Apikeys.talkspace_1099
|
||||
url_email = "https://api.northpass.com/v2/people?filter[email][eq]="
|
||||
import_list = "/Users/normrasmussen/Downloads/Compliance Payment - April.csv"
|
||||
|
||||
def getfromEmail(url_emil, apikey, import_list):
|
||||
with open(import_list, newline='') as csvfile:
|
||||
file = csv.reader(csvfile, delimiter=',')
|
||||
for items in file:
|
||||
email = items[0]
|
||||
url = url_email + f"{email}"
|
||||
headers = {
|
||||
"accept": "*/*",
|
||||
"x-api-key": apikey,
|
||||
"content-type": "application/json",
|
||||
}
|
||||
response = requests.get(url, headers=headers)
|
||||
if response.status_code == 200:
|
||||
response = response.json()
|
||||
for data in response["data"]:
|
||||
uuid = data["id"]
|
||||
items.append(uuid)
|
||||
add_multi_prop(items)
|
||||
else:
|
||||
print("Another Error!")
|
||||
|
||||
def add_multi_prop(items):
|
||||
email = items[0]
|
||||
role = items[1]
|
||||
id_num = items[2]
|
||||
paid = items[3].lower()
|
||||
# paid_bool = bool("TRUE")
|
||||
uuid = items[4]
|
||||
url = "https://api.northpass.com/v2/properties/people/bulk"
|
||||
payload = {"data": [
|
||||
{
|
||||
"type": "person_properties",
|
||||
"attributes": {"properties": {
|
||||
"paid": paid,
|
||||
"role_type": role,
|
||||
"user_id": id_num
|
||||
}},
|
||||
"id": uuid
|
||||
}
|
||||
]}
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"content-type": "application/json",
|
||||
"X-Api-Key": apikey}
|
||||
response = requests.post(url, json=payload, headers=headers)
|
||||
|
||||
if response.status_code == 404 or response.status_code == 403:
|
||||
print(f"Error {response.status_code} with user {email}")
|
||||
else:
|
||||
print(f"Successfully Added props for {email}!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
getfromEmail(url_email, apikey, import_list)
|
||||
Reference in New Issue
Block a user