Skip to content

Commit

Permalink
Adding addSecondaryEmail method and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicobraintly committed Jun 23, 2021
1 parent ad4d06d commit a2c2b91
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Resources/Contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,25 @@ public function deleteSecondaryEmail($id, $emailToDelete)
);
}

/**
* @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.
*
Expand Down
23 changes: 23 additions & 0 deletions tests/Integration/Resources/ContactsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit a2c2b91

Please sign in to comment.