diff --git a/src/Resources/Contacts.php b/src/Resources/Contacts.php index f881ffd6..c241abff 100644 --- a/src/Resources/Contacts.php +++ b/src/Resources/Contacts.php @@ -423,6 +423,44 @@ public function merge($id, $vidToMerge) ); } + /** + * @param int $id + * @param string $emailToDelete + * @return \SevenShores\Hubspot\Http\Response + * + * @see https://legacydocs.hubspot.com/docs/methods/contacts/delete-a-secondary-email-address + * + * @return \SevenShores\Hubspot\Http\Response + */ + public function deleteSecondaryEmail($id, $emailToDelete) + { + $endpoint = "https://api.hubapi.com/contacts/v1/secondary-email/{$id}/email/{$emailToDelete}"; + + return $this->client->request( + 'delete', + $endpoint + ); + } + + /** + * @param int $id + * @param string $emailToAdd + * @return \SevenShores\Hubspot\Http\Response + * + * @see https://legacydocs.hubspot.com/docs/methods/contacts/add-a-secondary-email-address + * + * @return \SevenShores\Hubspot\Http\Response + */ + public function addSecondaryEmail($id, $emailToAdd) + { + $endpoint = "https://api.hubapi.com/contacts/v1/secondary-email/{$id}/email/{$emailToAdd}"; + + return $this->client->request( + 'put', + $endpoint + ); + } + /** * Get Lifecycle Stage metrics for Contacts. * diff --git a/tests/Integration/Resources/ContactsTest.php b/tests/Integration/Resources/ContactsTest.php index 0c3f59f1..68278daa 100644 --- a/tests/Integration/Resources/ContactsTest.php +++ b/tests/Integration/Resources/ContactsTest.php @@ -230,6 +230,29 @@ public function statistics() $this->assertEquals(200, $response->getStatusCode()); } + /** @test */ + public function addSecondaryEmail() + { + $secondaryEmail = 'rw_test'.uniqid().'@hubspot.com'; + + $response = $this->resource->addSecondaryEmail($this->entity->vid, $secondaryEmail); + $this->assertEquals(200, $response->getStatusCode()); + } + + /** @test */ + public function deleteSecondaryEmail() + { + $secondaryEmail = 'rw_test'.uniqid().'@hubspot.com'; + + $response = $this->resource->addSecondaryEmail($this->entity->vid, $secondaryEmail); + $this->assertEquals(200, $response->getStatusCode()); + + sleep(1); + + $response = $this->resource->deleteSecondaryEmail($this->entity->vid, $secondaryEmail); + $this->assertEquals(200, $response->getStatusCode()); + } + /** @test */ public function getLifecycleStageMetrics() {