Added Supplier's API keys for their MX transfer
This commit is contained in:
@ -32,7 +32,8 @@ BLOOMERANG = "ewGDqLgsklMnytqzUka2wmgIi"
|
|||||||
GSU = "rUUKNuBZ0rmRNPftB4smYhQ5L"
|
GSU = "rUUKNuBZ0rmRNPftB4smYhQ5L"
|
||||||
EMPLOY = "qcNggCm4SBtC0gTqLGv30vX8l"
|
EMPLOY = "qcNggCm4SBtC0gTqLGv30vX8l"
|
||||||
LUMAFINTECH = "oDFA7XSmjEKjEwIDIKLm0rxs1"
|
LUMAFINTECH = "oDFA7XSmjEKjEwIDIKLm0rxs1"
|
||||||
SUPPLIERPROD = "DtRH9m4r0zMbJEx1yWBGKlObi"
|
SUPPLIERUSPROD = "DtRH9m4r0zMbJEx1yWBGKlObi"
|
||||||
|
SUPPLIERMXPROD = "zHIVw9dMzsNJLtFdqRXsJHGv3"
|
||||||
DEEPL = "fo5uOoG9FNNGQ6lZkenmZVIzq"
|
DEEPL = "fo5uOoG9FNNGQ6lZkenmZVIzq"
|
||||||
CECSINTERNAL = "r8KINCJRgkkQnrzzKitOJfsVw"
|
CECSINTERNAL = "r8KINCJRgkkQnrzzKitOJfsVw"
|
||||||
EMPLOYINC = "qcNggCm4SBtC0gTqLGv30vX8l"
|
EMPLOYINC = "qcNggCm4SBtC0gTqLGv30vX8l"
|
||||||
|
|||||||
58
Scripts/Walmart/Supplier/import_us_crece_to_mx.py
Normal file
58
Scripts/Walmart/Supplier/import_us_crece_to_mx.py
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import requests
|
||||||
|
import pprint
|
||||||
|
import pandas as pd
|
||||||
|
import Apikeys
|
||||||
|
|
||||||
|
pp = pprint.PrettyPrinter(indent=4)
|
||||||
|
APIKEY = Apikeys.SUPPLIER
|
||||||
|
HEADERS = {
|
||||||
|
"accept": "application/json",
|
||||||
|
"X-Api-Key": APIKEY,
|
||||||
|
}
|
||||||
|
BASEURL = "https://api.northpass.com/v2/"
|
||||||
|
IMPORTFILE = "/Users/normrasmussen/Downloads/supplierus-crece-for-mx-import.csv"
|
||||||
|
|
||||||
|
def main():
|
||||||
|
data = pd.read_csv(IMPORTFILE)
|
||||||
|
groups = data["Email"].unique()
|
||||||
|
groups = list(groups)
|
||||||
|
print("Here are all groups within the CSV:")
|
||||||
|
print(groups)
|
||||||
|
print(" ")
|
||||||
|
for group in groups:
|
||||||
|
payload = ""
|
||||||
|
print(group)
|
||||||
|
tmp_group = data[data.Group == group]
|
||||||
|
people = list(tmp_group["Email"])
|
||||||
|
group = str(tmp_group["Group"].unique())[2:-2]
|
||||||
|
print(f"Group --> {group} ... Amount of People --> {len(people)}")
|
||||||
|
url = f"{BASEURL}bulk/people"
|
||||||
|
if len(people) > 1500:
|
||||||
|
for chunk in range(0, len(people), 1500):
|
||||||
|
i = chunk
|
||||||
|
payload_1 = []
|
||||||
|
i_to_add = people[i : i + 1500]
|
||||||
|
for person in i_to_add:
|
||||||
|
miniload = {"email": person, "groups": group}
|
||||||
|
payload_1.append(miniload)
|
||||||
|
print(f"The long length {group} payload has {len(payload_1)}")
|
||||||
|
payload = {"data": {"attributes": {"people": payload_1}}}
|
||||||
|
response = requests.post(url, headers=HEADERS, json=payload)
|
||||||
|
print(f"Completed. Status code is {response.status_code}")
|
||||||
|
else:
|
||||||
|
payload_1 = []
|
||||||
|
for person in people:
|
||||||
|
miniload = {"email": person, "groups": group}
|
||||||
|
payload_1.append(miniload)
|
||||||
|
print(f"The {group} payload has {len(payload_1)}")
|
||||||
|
payload = {"data": {"attributes": {"people": payload_1}}}
|
||||||
|
response = requests.post(url, headers=HEADERS, json=payload)
|
||||||
|
print(f"Completed. Status code is {response.status_code}")
|
||||||
|
print(response.text)
|
||||||
|
print("Running add props from func...")
|
||||||
|
time.sleep(3)
|
||||||
|
add_props_from_func(people, data, group)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user