From daee99e12a185d6a781395ed87a84b5f2c503750 Mon Sep 17 00:00:00 2001 From: Alon Diamant Date: Fri, 22 Dec 2023 19:20:29 +0200 Subject: [PATCH] =?UTF-8?q?Added:=20support=20for=20the=20secondary=20emai?= =?UTF-8?q?l=20addresses=20(v1)=20API,=20following=20=E2=80=A6=20(#136)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hubspot3/contacts.py | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/hubspot3/contacts.py b/hubspot3/contacts.py index 9612620..9be71be 100644 --- a/hubspot3/contacts.py +++ b/hubspot3/contacts.py @@ -77,7 +77,7 @@ def merge(self, primary_id: int, secondary_id: int, **options): """merge the data from the secondary_id into the data of the primary_id""" data = dict(vidToMerge=secondary_id) - self._call( + return self._call( f"contact/merge-vids/{primary_id}/", data=data, method="POST", **options ) @@ -301,6 +301,46 @@ def delete_a_contact(self, contact_id: str, **options): ) return self.delete_by_id(contact_id, **options) + def get_secondary_emails(self, contact_id: str, **options): + """Get contact's secondary emails by its ID""" + return self._call(f"secondary-email/{contact_id}", method="GET", **options) + + def add_secondary_email(self, contact_id: str, email_address: str, **options): + """Add a secondary email to a contact""" + return self._call( + f"secondary-email/{contact_id}/email/{email_address}", + method="PUT", + **options, + ) + + def update_secondary_email( + self, + contact_id: str, + target_email_address: str, + updated_email_address: str, + **options, + ): + """Update the secondary email of a contact""" + data = { + "targetSecondaryEmail": target_email_address, + "updatedSecondaryEmail": updated_email_address, + } + + return self._call( + f"secondary-email/{contact_id}", + data=data, + method="PATCH", + **options, + ) + + def delete_secondary_email(self, contact_id: str, email_address: str, **options): + """Delete a secondary email of a contact""" + return self._call( + f"secondary-email/{contact_id}/email/{email_address}", + method="DELETE", + **options, + ) + def search(self, search_query: str, **options): """ Search among contacts for matches with the given `search_query`.