Skip to content

Commit

Permalink
fixing broken Contacts update method (#311)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
kevindeleon authored Aug 6, 2020
1 parent d74376e commit acb9f20
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ $client->contacts->create([
]);

/** Update a contact */
$client->contacts->update([
$client->contacts->update("570680a8a1bcbca8a90001b9", [
"email" => "[email protected]",
"custom_attributes" => ['foo' => 'bar']
]);
Expand Down
6 changes: 4 additions & 2 deletions src/IntercomContacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ public function create(array $options)
* Updates a Contact.
*
* @see https://developers.intercom.com/intercom-api-reference/reference#update-contact
* @param string $id
* @param array $options
* @return stdClass
* @throws Exception
*/
public function update(array $options)
public function update(string $id, array $options)
{
return $this->client->put("contacts", $options);
$path = $this->contactPath($id);
return $this->client->put($path, $options);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/IntercomContactsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function testContactUpdate()
$this->client->method('put')->willReturn('foo');

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

public function testContactsGet()
Expand Down

0 comments on commit acb9f20

Please sign in to comment.