Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't figure out how to update a contact #27

Open
pdath opened this issue May 10, 2024 · 1 comment
Open

I can't figure out how to update a contact #27

pdath opened this issue May 10, 2024 · 1 comment

Comments

@pdath
Copy link

pdath commented May 10, 2024

I'm trying to update a phone number in a contact (actually lots and lots of contacts). I start out going:

paginated_contacts = manage_api_client.company.contacts.paginated(1,00)
for contact in paginated_contacts.all():
...
contact.default_phone_nbr="xxx"

How do I post that update?
manage_api_client.company.contacts.post(contact)
contact.post()
I can't seem to guess the syntax.

@pdath
Copy link
Author

pdath commented May 22, 2024

For anyone finding this in the future I finally figured it out. Basically to update a field (like phone number) you do something like:

paginated_contacts = manage_api_client.company.contacts.paginated(1,00)
for contact in paginated_contacts.all():
# Skip records with no contact info at all
if(contact.communication_items) is None:
continue;

for communication in contact.communication_items:
	# Only process contact phone numbers
	if(not(communication.type.name=="Direct" or communication.type.name=="Mobile" or communication.type.name=="Home")):
		continue;

	payload = [{"op": "replace", "path": "value", "value": "+1(813)0005555"}]
	manage_api_client.company.contacts.id(contact.id).communications.id(communication.id).patch(payload)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant