63 lines
1.7 KiB
Python
63 lines
1.7 KiB
Python
import requests
|
|
import Apikeys
|
|
import pprint
|
|
|
|
|
|
|
|
pp=pprint.PrettyPrinter(indent=4)
|
|
APIKEY = Apikeys.DEEPL
|
|
BASEURL = "https://api.northpass.com/v2"
|
|
HEADERS = {
|
|
"accept": "application/json",
|
|
"X-Api-Key": APIKEY
|
|
}
|
|
|
|
def get_people():
|
|
count = 1
|
|
while True:
|
|
ppl_uuids = []
|
|
url = f"{BASEURL}/people?page={count}&limit=100"
|
|
print(url)
|
|
count += 1
|
|
response = requests.get(url, headers=HEADERS).json()
|
|
nextlink = response["links"]
|
|
for data in response['data']:
|
|
person_uuid = data['id']
|
|
if person_uuid == "c09c6319-7569-46ac-94d5-3885d9de4c2f" or person_uuid == "477de2a1-15cc-4d67-9e95-7e3910dca5d3":
|
|
print("Found Claudia or Fabian")
|
|
print(person_uuid)
|
|
print(data['attributes']['full_name'])
|
|
ppl_uuids.append(person_uuid)
|
|
if len(ppl_uuids) == 100:
|
|
apply_prop(ppl_uuids)
|
|
# break
|
|
|
|
if "next" not in nextlink:
|
|
break
|
|
|
|
def apply_prop(ppl_uuids):
|
|
inserted_load = []
|
|
for person in ppl_uuids:
|
|
miniload = {
|
|
"attributes": { "properties": { "new_content": "True" } },
|
|
"id": person,
|
|
"type": "person_properties"
|
|
}
|
|
inserted_load.append(miniload)
|
|
prop_url = f"{BASEURL}/properties/people/bulk"
|
|
payload = { "data": inserted_load }
|
|
print(payload)
|
|
apply_payload = requests.post(prop_url, json=payload, headers=HEADERS)
|
|
stat = apply_payload.status_code
|
|
print(stat)
|
|
if "4" in str(stat):
|
|
print("....!")
|
|
print("Error! Error!")
|
|
print(stat.text)
|
|
print(payload)
|
|
print("....!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
get_people()
|