New script for Karbon. Luminate and Williams-Sonoma template updates.
This commit is contained in:
40
Scripts/Karbon/update_groups_remove_ppl_from_groups.py
Normal file
40
Scripts/Karbon/update_groups_remove_ppl_from_groups.py
Normal file
@ -0,0 +1,40 @@
|
||||
import Apikeys
|
||||
import requests
|
||||
import pandas as pd
|
||||
|
||||
IMPORTFILE = '~/Downloads/karbon-existing-groups.csv'
|
||||
APIKEY = Apikeys.KARBON
|
||||
HEADERS = {"accept": "application/json", "X-Api-Key": APIKEY }
|
||||
BASEURL = "https://api.northpass.com/v2/"
|
||||
|
||||
|
||||
def grab_groups():
|
||||
groups_list = []
|
||||
df = pd.read_csv(IMPORTFILE)
|
||||
df2 = df[[ "customer_id", "customer_name" ]].copy()
|
||||
df2.drop_duplicates(subset="customer_id", keep=False, inplace=True)
|
||||
for row in df2.itertuples():
|
||||
group = f"{row[2]}--{row[1]}"
|
||||
cust_id = row[1]
|
||||
groups_list.append(( group, cust_id ))
|
||||
|
||||
for item in groups_list:
|
||||
print(item)
|
||||
get_group_url = f"{BASEURL}groups?filter[name][cont]={item[1]}"
|
||||
try:
|
||||
response = requests.get(get_group_url, headers=HEADERS)
|
||||
resp = response.json()
|
||||
print("-----------------")
|
||||
print(response.status_code)
|
||||
print(resp['data'][0]['attributes']['name'])
|
||||
print(item)
|
||||
print("-----------------")
|
||||
except IndexError as e:
|
||||
print(e)
|
||||
print(resp['data'])
|
||||
finally:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
grab_groups()
|
||||
Reference in New Issue
Block a user