Skip to content

Commit

Permalink
Added: support for the secondary email addresses (v1) API, following … (
Browse files Browse the repository at this point in the history
  • Loading branch information
advance512 authored Dec 22, 2023
1 parent f8806f3 commit daee99e
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion hubspot3/contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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`.
Expand Down

0 comments on commit daee99e

Please sign in to comment.