Implements 2.0 Contacts Endpoint methods and Conversation Search#306
Implements 2.0 Contacts Endpoint methods and Conversation Search#306GabrielAnca merged 12 commits intomasterfrom
Conversation
…sor pagination for contacts.
GabrielAnca
left a comment
There was a problem hiding this comment.
This looks great @lloydliyu! Very happy to see this happening in the PHP SDK! Lots of people will be very happy.
Made a first pass on the code itself and left some feedback 🙌
README.md
Outdated
| $client->contacts->getContact("570680a8a1bcbca8a90001b9"); | ||
|
|
||
| /** Add companies to a contact */ | ||
| $client->contacts->create([ |
There was a problem hiding this comment.
Even though technically it's also a call to POST /contacts, I would prefer to have two explicit methods in the IntercomCompanies resource to make this more straightforward, ie $client->companies->attachContact($id) & $client->companies->detachContact($id). I think that would make using this SDK more straightforward, even though they could also do it this way. It would also make the SDK more similar to our API docs 😃
There was a problem hiding this comment.
I agree, I believe aligning it as close to the API documentation is ideal, plus the additional ease-of-use. On the API documentation, both a contact_id and id (for the company) are required, so should the method incorporate both parameters? In the example you gave, only $id is specified. (I apologize if I'm missing something, I'm relatively new to this repository)
src/IntercomContacts.php
Outdated
| * @return stdClass | ||
| * @throws Exception | ||
| */ | ||
| public function getContacts(array $options) |
There was a problem hiding this comment.
Let's add a default here so we don't need to pass empty arrays when we want to make a full list request 😄
| public function getContacts(array $options) | |
| public function getContacts(array $options = []) |
src/IntercomContacts.php
Outdated
| * @return stdClass | ||
| * @throws Exception | ||
| */ | ||
| public function getContact($id, $options = []) |
There was a problem hiding this comment.
I'm a strongly typing fan 😅
| public function getContact($id, $options = []) | |
| public function getContact($id, array $options = []) |
src/IntercomContacts.php
Outdated
| return $this->client->nextSearchPage($path, $query, $pages); | ||
| } | ||
|
|
||
| /** Returns next page of a Contacts list. |
There was a problem hiding this comment.
| /** Returns next page of a Contacts list. | |
| /** | |
| * Returns next page of a Contacts list. |
src/IntercomContacts.php
Outdated
| * Returns next page of Contacts that match search query. | ||
| * | ||
| * @see https://developers.intercom.com/intercom-api-reference/reference#pagination-search | ||
| * @param array $options |
There was a problem hiding this comment.
From here to the end of the file there are some methods where the phpdocs don't match the method params 😃
src/IntercomClient.php
Outdated
| "starting_after" => $pages->next->starting_after, | ||
| ] | ||
| ]; | ||
| $response = $this->sendRequest('POST', "https://api.intercom.io/$path", $options); |
There was a problem hiding this comment.
In order to avoid hardcoding the URL in multiple places, why don't we call $this->post here?
| $response = $this->sendRequest('POST', "https://api.intercom.io/$path", $options); | |
| $response = $this->post($path, $options); |
Same for the next method
RaneLafraze
left a comment
There was a problem hiding this comment.
I started to explore this SDK repository today and was disappointed to see it has fallen behind in terms of compatibility. I plan to invest some time in helping update this repository, and I'm happy to help in whatever way I can!
README.md
Outdated
| $client->contacts->getContact("570680a8a1bcbca8a90001b9"); | ||
|
|
||
| /** Add companies to a contact */ | ||
| $client->contacts->create([ |
There was a problem hiding this comment.
I agree, I believe aligning it as close to the API documentation is ideal, plus the additional ease-of-use. On the API documentation, both a contact_id and id (for the company) are required, so should the method incorporate both parameters? In the example you gave, only $id is specified. (I apologize if I'm missing something, I'm relatively new to this repository)
* Create dedicated attach and detach methods * Use post and get methods instead of sendRequest() * Add default value and update phpdocs * Lint fixes * Change string concatenation for consistency Co-authored-by: Gabriel Anca Corral <GabrielAnca@users.noreply.github.com> * Add companyId parameter and add types * Add method to generate detach contact request path * Add typing for parameter Co-authored-by: Gabriel Anca Corral <GabrielAnca@users.noreply.github.com> Co-authored-by: Gabriel Anca Corral <GabrielAnca@users.noreply.github.com>
Co-authored-by: Rane Lafraze <lafrazeRL@gmail.com>
GabrielAnca
left a comment
There was a problem hiding this comment.
Looks great to me, thank you so much for your effort @lloydliyu and @RaneLafraze 🚀 Let's wait for @lloydliyu to have a look at the latest changes and we'll be ready to ship 😄
|
Got Daniel's approval separately and we are good to go. I'll be merging this PR. Before releasing a new version, I will make a separate PR that will update the README |
Why?
Brings Contacts and Conversation support in SDK up to 2.0.
Closes #293
How?