Skip to content

Commit acb9f20

Browse files
authored
fixing broken Contacts update method (intercom#311)
* fixing broken update method "update" should follow the same pattern as other methods like deleteContact and getContact that require "id" based on the API documentation. * updates tests and README for broken Contact method
1 parent d74376e commit acb9f20

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ $client->contacts->create([
6666
]);
6767

6868
/** Update a contact */
69-
$client->contacts->update([
69+
$client->contacts->update("570680a8a1bcbca8a90001b9", [
7070
"email" => "[email protected]",
7171
"custom_attributes" => ['foo' => 'bar']
7272
]);

src/IntercomContacts.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ public function create(array $options)
2424
* Updates a Contact.
2525
*
2626
* @see https://developers.intercom.com/intercom-api-reference/reference#update-contact
27+
* @param string $id
2728
* @param array $options
2829
* @return stdClass
2930
* @throws Exception
3031
*/
31-
public function update(array $options)
32+
public function update(string $id, array $options)
3233
{
33-
return $this->client->put("contacts", $options);
34+
$path = $this->contactPath($id);
35+
return $this->client->put($path, $options);
3436
}
3537

3638
/**

test/IntercomContactsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function testContactUpdate()
2020
$this->client->method('put')->willReturn('foo');
2121

2222
$contacts = new IntercomContacts($this->client);
23-
$this->assertSame('foo', $contacts->update([]));
23+
$this->assertSame('foo', $contacts->update('', []));
2424
}
2525

2626
public function testContactsGet()

0 commit comments

Comments
 (0)