-
Notifications
You must be signed in to change notification settings - Fork 141
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
Contact & Conversation Tagging / Articles / Messages #314
base: master
Are you sure you want to change the base?
Changes from 33 commits
8a5d433
12cf8ae
42b9d6a
19a20b3
8f34502
0d972de
b0a1b61
2b613bd
cbb6bab
d52084e
c752909
966ab4a
3adef45
c73965c
9a1fdea
074574f
217e059
64a24e5
ef7029e
ddda8f6
760ffca
494c770
7c5bc59
5a1d17f
52a8dab
f748109
eaa8f78
de1ed0d
fd620d1
e8fc1be
027baf1
484a7d8
14f8bfa
af555c6
d5ca224
2bd694d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -90,6 +90,12 @@ $client->contacts->nextSearch($query, $response->pages); | |||||||||||||||||||
|
||||||||||||||||||||
/** List all contacts */ | ||||||||||||||||||||
$client->contacts->getContacts([]); | ||||||||||||||||||||
|
||||||||||||||||||||
/** Tag a Contact */ | ||||||||||||||||||||
$client->contacts->addTag("570680a8a1bcbca8a90001b9", "2084335"); | ||||||||||||||||||||
|
||||||||||||||||||||
/** Remove a Tag from a Contact */ | ||||||||||||||||||||
$client->contacts->removeTag("570680a8a1bcbca8a90001b9", "2084335"); | ||||||||||||||||||||
``` | ||||||||||||||||||||
|
||||||||||||||||||||
## Users | ||||||||||||||||||||
|
@@ -489,6 +495,25 @@ $client->teams->getTeams(); | |||||||||||||||||||
$client->teams->getTeam("1188"); | ||||||||||||||||||||
``` | ||||||||||||||||||||
|
||||||||||||||||||||
## Articles | ||||||||||||||||||||
|
||||||||||||||||||||
```php | ||||||||||||||||||||
/** Create an Article */ | ||||||||||||||||||||
$client->articles->create(["title" => "How To Use the Intercom API", "description" => "A quick guide to the universe of the Intercom API", "body" => "<p>This is the body in html</p>", "author_id" => 1]); | ||||||||||||||||||||
|
||||||||||||||||||||
/** Retrieve an Article */ | ||||||||||||||||||||
$client->articles->getArticle("123456"); | ||||||||||||||||||||
|
||||||||||||||||||||
/** Update an Article */ | ||||||||||||||||||||
$client->articles->update("123456", ["title" => "How To Use the Intercom API", "description" => "A quick guide to the universe of the Intercom API", "body" => "<p>This is the body in html</p>"); | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here 😃
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
/** Delete an Article */ | ||||||||||||||||||||
$client->articles->deleteArticle("123456"); | ||||||||||||||||||||
|
||||||||||||||||||||
/** List Articles */ | ||||||||||||||||||||
$client->articles->getArticles(); | ||||||||||||||||||||
``` | ||||||||||||||||||||
|
||||||||||||||||||||
|
||||||||||||||||||||
## Rate Limits | ||||||||||||||||||||
|
||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
namespace Intercom; | ||
|
||
use Http\Client\Exception; | ||
use stdClass; | ||
|
||
class IntercomArticles extends IntercomResource | ||
{ | ||
/** | ||
* Creates an Article. | ||
* | ||
* @see https://developers.intercom.com/intercom-api-reference/v0/reference#create-an-article | ||
* @param array $options | ||
* @return stdClass | ||
* @throws Exception | ||
*/ | ||
public function create(array $options) | ||
{ | ||
return $this->client->post("articles", $options); | ||
} | ||
|
||
/** | ||
* Gets a single Article based on the Article ID. | ||
* | ||
* @see https://developers.intercom.com/intercom-api-reference/v0/reference#retrieve-an-article | ||
* @param string $id | ||
* @param array $options | ||
* @return stdClass | ||
* @throws Exception | ||
*/ | ||
public function getArticle(string $id, array $options = []) | ||
{ | ||
$path = $this->articlePath($id); | ||
return $this->client->get($path, $options); | ||
} | ||
|
||
/** | ||
* Updates an existing Article | ||
* | ||
* @see https://developers.intercom.com/intercom-api-reference/v0/reference#update-an-article | ||
* @param string $id | ||
* @param array $options | ||
* @return stdClass | ||
*/ | ||
public function update(string $id, array $options = []) | ||
{ | ||
$path = $this->articlePath($id); | ||
return $this->client->put($path, $options); | ||
} | ||
|
||
/** | ||
* Deletes a single article based on the Article ID. | ||
* | ||
* @see https://developers.intercom.com/intercom-api-reference/v0/reference#delete-an-article | ||
* @param string $id | ||
* @param array $options | ||
* @return stdClass | ||
* @throws Exception | ||
*/ | ||
public function deleteArticle(string $id, array $options = []) | ||
{ | ||
$path = $this->articlePath($id); | ||
return $this->client->delete($path, $options); | ||
} | ||
|
||
/** | ||
* Lists Articles. | ||
* | ||
* @see https://developers.intercom.com/intercom-api-reference/v0/reference#list-all-articles | ||
* @param array $options | ||
* @return stdClass | ||
* @throws Exception | ||
*/ | ||
public function getArticles(array $options = []) | ||
{ | ||
return $this->client->get('articles', $options); | ||
} | ||
|
||
/** | ||
* @param string $id | ||
* @return string | ||
*/ | ||
public function articlePath(string $id) | ||
{ | ||
return 'articles/' . $id; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,16 @@ class IntercomClient | |
*/ | ||
public $users; | ||
|
||
/** | ||
* @var IntercomContacts $contacts | ||
*/ | ||
public $contacts; | ||
|
||
/** | ||
* @var IntercomCustomers $customers | ||
*/ | ||
//public $customers; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is work in progress, but wanted to add a reminder that this and its initializer are commented out 😄 |
||
|
||
/** | ||
* @var IntercomEvents $events | ||
*/ | ||
|
@@ -68,11 +78,6 @@ class IntercomClient | |
*/ | ||
public $companies; | ||
|
||
/** | ||
* @var IntercomContacts $contacts | ||
*/ | ||
public $contacts; | ||
|
||
/** | ||
* @var IntercomMessages $messages | ||
*/ | ||
|
@@ -144,13 +149,15 @@ public function __construct(string $appIdOrToken, string $password = null, array | |
{ | ||
$this->users = new IntercomUsers($this); | ||
$this->contacts = new IntercomContacts($this); | ||
//$this->customers = new IntercomCustomers($this); | ||
$this->events = new IntercomEvents($this); | ||
$this->companies = new IntercomCompanies($this); | ||
$this->messages = new IntercomMessages($this); | ||
$this->conversations = new IntercomConversations($this); | ||
$this->leads = new IntercomLeads($this); | ||
$this->visitors = new IntercomVisitors($this); | ||
$this->admins = new IntercomAdmins($this); | ||
$this->articles = new IntercomArticles($this); | ||
$this->tags = new IntercomTags($this); | ||
$this->segments = new IntercomSegments($this); | ||
$this->counts = new IntercomCounts($this); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
<?php | ||
|
||
namespace Intercom; | ||
|
||
use Http\Client\Exception; | ||
|
@@ -21,17 +20,18 @@ public function create(array $options) | |
} | ||
|
||
/** | ||
* Updates a Contact. | ||
* Updates an existing Contact | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems these lines are a bit off 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Woops. Fixing |
||
* | ||
* @see https://developers.intercom.com/intercom-api-reference/reference#update-contact | ||
* @param string $id | ||
* @param array $options | ||
* @return stdClass | ||
* @throws Exception | ||
*/ | ||
|
||
public function update(string $id, array $options) | ||
{ | ||
$path = $this->contactPath($id); | ||
|
||
return $this->client->put($path, $options); | ||
} | ||
|
||
|
@@ -43,6 +43,7 @@ public function update(string $id, array $options) | |
* @return stdClass | ||
* @throws Exception | ||
*/ | ||
|
||
public function getContacts(array $options = []) | ||
{ | ||
return $this->client->get('contacts', $options); | ||
|
@@ -57,6 +58,7 @@ public function getContacts(array $options = []) | |
* @return stdClass | ||
* @throws Exception | ||
*/ | ||
|
||
public function getContact(string $id, array $options = []) | ||
{ | ||
$path = $this->contactPath($id); | ||
|
@@ -78,6 +80,38 @@ public function deleteContact(string $id, array $options = []) | |
return $this->client->delete($path, $options); | ||
} | ||
|
||
/** | ||
* Applys a tag to a Contact based on the provided Tag ID | ||
* | ||
* @see https://developers.intercom.com/intercom-api-reference/reference#tag-contact | ||
* @param string $id | ||
* @param string $tagId | ||
* @return stdClass | ||
* @throws Exception | ||
*/ | ||
public function addTag(string $id, string $tagId) | ||
{ | ||
$path = $this->contactTagsPath($id); | ||
|
||
return $this->client->post($path, ['id' => $tagId]); | ||
} | ||
|
||
/** | ||
* Removes a tag from a Contact based on the provided Tag ID | ||
* | ||
* @see https://developers.intercom.com/intercom-api-reference/reference#untag-contact | ||
* @param string $id | ||
* @param string $tagId | ||
* @return stdClass | ||
* @throws Exception | ||
*/ | ||
public function removeTag(string $id, string $tagId) | ||
{ | ||
$path = $this->contactTagsPath($id); | ||
|
||
return $this->client->delete($path, ['id' => $tagId]); | ||
} | ||
|
||
/** | ||
* Returns list of Contacts that match search query. | ||
* | ||
|
@@ -130,4 +164,15 @@ public function contactPath(string $id) | |
{ | ||
return 'contacts/' . $id; | ||
} | ||
|
||
/** | ||
* Returns the path for adding/removing a tag for a given contact | ||
* | ||
* @param string $id Contact ID | ||
* @return string | ||
*/ | ||
public function contactTagsPath(string $id) | ||
{ | ||
return 'contacts/' . $id . '/tags'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,45 @@ public function create($options) | |
{ | ||
return $this->client->post("messages", $options); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The message export feature is on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. We actually use it in a production system at the moment hence why we built it. Move to a beta branch or something? |
||
/** | ||
* Creates Message Export Job | ||
* | ||
* @see https://developers.intercom.com/intercom-api-reference/reference#creating-an-export-job | ||
* @param array $options | ||
* @return stdClass | ||
* @throws Exception | ||
*/ | ||
public function createExport($options) | ||
{ | ||
return $this->client->post("export/messages/data", $options); | ||
} | ||
|
||
/** | ||
* Retrieves Export Job Status | ||
* | ||
* @see https://developers.intercom.com/intercom-api-reference/reference#checking-the-status-of-the-job | ||
* @param string $job_identifier | ||
* @return stdClass | ||
* @throws Exception | ||
*/ | ||
public function retrieveExportStatus($job_identifier) | ||
{ | ||
return $this->client->get("export/messages/data/" . $job_identifier, []); | ||
} | ||
|
||
/** | ||
* Retrieves Export Job Data | ||
* | ||
* Important: The Intercom Client Accept Header must be application/octet-stream | ||
* | ||
* @see https://developers.intercom.com/intercom-api-reference/reference#downloading-the-data | ||
* @param string $job_identifier | ||
* @return stdClass | ||
* @throws Exception | ||
*/ | ||
public function retrieveExportData($job_identifier) | ||
{ | ||
return $this->client->get("download/messages/data/" . $job_identifier, []); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would love to split this into multiple lines: