-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateAssociateAccountType.py
More file actions
44 lines (32 loc) · 1.31 KB
/
updateAssociateAccountType.py
File metadata and controls
44 lines (32 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from utils import associates, files, utils
def main(env, orgId, user_name):
answer = utils.select_answer(question=">> Do you have an associate ID? ")
if answer == "Y":
associate = associates.get_associate_by_id(env, orgId, False)
else:
associate = associates.get_associate_by_name_or_email(env, orgId, False)
if associate is None:
print("Associate not found! Quitting program")
return
new_account_type = input(">> What would you like to be the new account type?\n> ")
bkp = associate
associate["associateType"] = new_account_type
response = associates.update_associate_data(env, associate, user_name)
if not response:
print(
"There was an error updating the associate, nothing was returned by the API"
)
return
if response.status_code >= 400:
print("There was an error updating the associate, check the error below:")
print(response.text)
return
print(
f"Updated {associate['associateId']} from {bkp['associateType']} to {new_account_type}"
)
files.save_json_to_file(associate, "CHANGE_ASSOCIATE_ACCOUNT_TYPE")
if __name__ == "__main__":
env = utils.select_env()
orgId = utils.select_org(env)
user_name = input("What is your name?\n> ")
main(env, orgId, user_name)