diff --git a/README.md b/README.md index 3fd8ad3..0727c69 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,12 @@ $client->contacts->deleteContact('570680a8a1bcbca8a90001b9'); /** Get a contact by ID */ $client->contacts->getContact('570680a8a1bcbca8a90001b9'); +/** Merge a contact to a User */ +$client->contacts->mergeContact([ + 'from' => '570680a8a1bcbca8a90001b9', + 'into' => '59c124f770e00fd819b9ce81', +]); + /** Search for contacts */ $query = ['field' => 'name', 'operator' => '=', 'value' => 'Alice']; $client->contacts->search([ diff --git a/src/IntercomContacts.php b/src/IntercomContacts.php index 7cfc073..6cd59e1 100644 --- a/src/IntercomContacts.php +++ b/src/IntercomContacts.php @@ -78,6 +78,19 @@ public function deleteContact(string $id, array $options = []) return $this->client->delete($path, $options); } + /** + * Merge a contact to a User. + * + * @see https://developers.intercom.com/intercom-api-reference/reference#merge-contact + * @param array $options + * @return stdClass + * @throws Exception + */ + public function mergeContact(array $options) + { + return $this->client->post("contacts/merge", $options); + } + /** * Returns list of Contacts that match search query. * diff --git a/tests/IntercomContactsTest.php b/tests/IntercomContactsTest.php index 9d1578d..dfaa947 100644 --- a/tests/IntercomContactsTest.php +++ b/tests/IntercomContactsTest.php @@ -47,6 +47,14 @@ public function testContactDelete() $this->assertSame('foo', $contacts->deleteContact('')); } + public function testContactMerge() + { + $this->client->method('post')->willReturn('foo'); + + $contacts = new IntercomContacts($this->client); + $this->assertSame('foo', $contacts->mergeContact([])); + } + public function testContactSearch() { $this->client->method('post')->willReturn('foo');