-
Notifications
You must be signed in to change notification settings - Fork 145
Implements 2.0 Contacts Endpoint methods and Conversation Search #306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c2726e2
Adds 2.0 contact methods
52d2032
Adds contact methods to readme.
5ee1845
Corrects search for contacts
7ee8a92
Removes customers endpoint as this is no longer available in the API
d57e9a5
Adds conversation search
8f9c30a
Adds conversation search to Readme.
3b3b275
Adds in search pagination for contacts and conversations, adds in cur…
d772283
Potential fix for tests
3c2ca35
lint fixes
8a20228
Dan.c/2.0 (#307)
RaneLafraze 36744cc
Apply suggested docs changes
GabrielAnca eb6a091
Minor docs and method arguments fixes
GabrielAnca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| <?php | ||
|
|
||
| namespace Intercom; | ||
|
|
||
| use Http\Client\Exception; | ||
| use stdClass; | ||
|
|
||
| class IntercomContacts extends IntercomResource | ||
| { | ||
| /** | ||
| * Creates a Contact. | ||
| * | ||
| * @see https://developers.intercom.com/intercom-api-reference/reference#create-contact | ||
| * @param array $options | ||
| * @return stdClass | ||
| * @throws Exception | ||
| */ | ||
| public function create(array $options) | ||
| { | ||
| return $this->client->post("contacts", $options); | ||
| } | ||
|
|
||
| /** | ||
| * Updates a Contact. | ||
| * | ||
| * @see https://developers.intercom.com/intercom-api-reference/reference#update-contact | ||
| * @param array $options | ||
| * @return stdClass | ||
| * @throws Exception | ||
| */ | ||
| public function update(array $options) | ||
| { | ||
| return $this->client->put("contacts", $options); | ||
| } | ||
|
|
||
| /** | ||
| * Lists Contacts. | ||
| * | ||
| * @see https://developers.intercom.com/intercom-api-reference/reference#list-contacts | ||
| * @param array $options | ||
| * @return stdClass | ||
| * @throws Exception | ||
| */ | ||
| public function getContacts(array $options = []) | ||
| { | ||
| return $this->client->get('contacts', $options); | ||
| } | ||
|
|
||
| /** | ||
| * Gets a single Contact based on the Intercom ID. | ||
| * | ||
| * @see https://developers.intercom.com/intercom-api-reference/reference#get-contact | ||
| * @param string $id | ||
| * @param array $options | ||
| * @return stdClass | ||
| * @throws Exception | ||
| */ | ||
| public function getContact(string $id, array $options = []) | ||
| { | ||
| $path = $this->contactPath($id); | ||
| return $this->client->get($path, $options); | ||
| } | ||
|
|
||
| /** | ||
| * Permenently Deletes a single Contact based on the Intercom ID. | ||
| * | ||
| * @see https://developers.intercom.com/intercom-api-reference/reference#delete-contact | ||
| * @param string $id | ||
| * @param array $options | ||
| * @return stdClass | ||
| * @throws Exception | ||
| */ | ||
| public function deleteContact(string $id, array $options = []) | ||
| { | ||
| $path = $this->contactPath($id); | ||
| return $this->client->delete($path, $options); | ||
| } | ||
|
|
||
| /** | ||
| * Returns list of Contacts that match search query. | ||
| * | ||
| * @see https://developers.intercom.com/reference#search-for-contacts | ||
| * @param array $options | ||
| * @return stdClass | ||
| * @throws Exception | ||
| */ | ||
| public function search(array $options) | ||
| { | ||
| $path = 'contacts/search'; | ||
| return $this->client->post($path, $options); | ||
| } | ||
|
|
||
| /** | ||
| * Returns next page of Contacts that match search query. | ||
| * | ||
| * @see https://developers.intercom.com/intercom-api-reference/reference#pagination-search | ||
| * @param array $query | ||
| * @param stdClass $pages | ||
| * @return stdClass | ||
| * @throws Exception | ||
| */ | ||
| public function nextSearch(array $query, $pages) | ||
GabrielAnca marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| $path = 'contacts/search'; | ||
| return $this->client->nextSearchPage($path, $query, $pages); | ||
| } | ||
|
|
||
| /** | ||
| * Returns next page of a Contacts list. | ||
| * | ||
| * @see https://developers.intercom.com/intercom-api-reference/reference#pagination | ||
| * @param stdClass $pages | ||
| * @return stdClass | ||
| * @throws Exception | ||
| */ | ||
| public function nextCursor($pages) | ||
| { | ||
| $path = 'contacts'; | ||
| $starting_after = $pages->next->starting_after; | ||
| return $this->client->nextCursorPage($path, $starting_after); | ||
| } | ||
|
|
||
| /** | ||
| * @param string $id | ||
| * @return string | ||
| */ | ||
| public function contactPath(string $id) | ||
| { | ||
| return 'contacts/' . $id; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.