From a5d4bebd374354c18c08d43d2a8b8343dc037955 Mon Sep 17 00:00:00 2001 From: kei1111 Date: Sun, 30 Jan 2022 14:38:29 +0900 Subject: [PATCH 1/3] Add merge contact method --- src/IntercomContacts.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/IntercomContacts.php b/src/IntercomContacts.php index 7cfc0739..6cd59e16 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. * From e2cc32c771f80a2dd57760ad8476b9fdc0cf65bd Mon Sep 17 00:00:00 2001 From: kei1111 Date: Sun, 30 Jan 2022 14:56:59 +0900 Subject: [PATCH 2/3] Add test of merge contact method --- tests/IntercomContactsTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/IntercomContactsTest.php b/tests/IntercomContactsTest.php index 9d1578d5..dfaa9478 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'); From f83bd153784ef97cc96fb86d06f4976924d1f761 Mon Sep 17 00:00:00 2001 From: kei1111 Date: Sun, 30 Jan 2022 14:58:09 +0900 Subject: [PATCH 3/3] Add merge contact method's description to README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 3fd8ad38..0727c691 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([