Talkspace script for emails into props, G2, and Wild Health Notes.
This commit is contained in:
@ -4,7 +4,7 @@ from pathlib import Path
|
||||
import Apikeys
|
||||
import os
|
||||
|
||||
basefile = "/Users/normrasmussen/Downloads/MizunoAug_Completions.csv"
|
||||
basefile = "/Users/normrasmussen/Downloads/Mizuno-September23-Completions.csv"
|
||||
api_key = Apikeys.mizuno
|
||||
uuid_url = "https://api.northpass.com/v2/people?filter[email][eq]="
|
||||
prop_url = "https://api.northpass.com/v2/properties/people/"
|
||||
@ -51,7 +51,7 @@ def load_file(basefile):
|
||||
# completions = completions.iloc[:, 0:]
|
||||
print(completions)
|
||||
completions.to_csv(
|
||||
"/Users/normrasmussen/Downloads/MizunoCompletions_with_PGAIDs.csv",
|
||||
"/Users/normrasmussen/Downloads/Mizuno-09.23-Completions_with_PGAIDs.csv",
|
||||
index=False,
|
||||
)
|
||||
|
||||
|
||||
@ -4,8 +4,8 @@ from pathlib import Path
|
||||
import Apikeys
|
||||
import os
|
||||
|
||||
basefile = "/Users/normrasmussen/Downloads/client-learners.csv"
|
||||
api_key = Apikeys.wildhealth_edportal
|
||||
basefile = "/Users/normrasmussen/Downloads/talkspace-paid-learners.csv"
|
||||
api_key = Apikeys.talkspace_1099
|
||||
prop_url = "https://api.northpass.com/v2/properties/people/"
|
||||
headers = {
|
||||
"accept": "*/*",
|
||||
|
||||
55
Scripts/API_Tests/update_prop_from_email.py
Normal file
55
Scripts/API_Tests/update_prop_from_email.py
Normal file
@ -0,0 +1,55 @@
|
||||
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/Talkspace-bulk.csv"
|
||||
|
||||
def getfromEmail(url_email, apikey, import_list):
|
||||
uuid = ""
|
||||
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)
|
||||
# print(uuid)
|
||||
add_multi_prop(uuid)
|
||||
else:
|
||||
print("Another Error!")
|
||||
|
||||
def add_multi_prop(uuid):
|
||||
url = "https://api.northpass.com/v2/properties/people/bulk"
|
||||
payload = {"data": [
|
||||
{
|
||||
"type": "person_properties",
|
||||
"attributes": {"properties": {
|
||||
"paid": "true",
|
||||
}},
|
||||
"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 {uuid}")
|
||||
else:
|
||||
print(f"Successfully Added props for {uuid}!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
getfromEmail(url_email, apikey, import_list)
|
||||
Reference in New Issue
Block a user