-
Notifications
You must be signed in to change notification settings - Fork 146
Contact & Conversation Tagging / Articles / Messages #314
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
base: master
Are you sure you want to change the base?
Changes from 30 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 |
|---|---|---|
| @@ -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($id, $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 array $options | ||
|
||
| * @return stdClass | ||
| * @throws Exception | ||
| */ | ||
| public function update($id, $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 | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,4 @@ | ||||||
| <?php | ||||||
|
|
||||||
| namespace Intercom; | ||||||
|
|
||||||
| use Http\Client\Exception; | ||||||
|
|
@@ -25,13 +24,18 @@ public function create(array $options) | |||||
| * | ||||||
| * @see https://developers.intercom.com/intercom-api-reference/reference#update-contact | ||||||
| * @param string $id | ||||||
| * Updates an existing Contact | ||||||
|
Contributor
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 😅
Author
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 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 +47,7 @@ public function update(string $id, array $options) | |||||
| * @return stdClass | ||||||
| * @throws Exception | ||||||
| */ | ||||||
|
|
||||||
| public function getContacts(array $options = []) | ||||||
| { | ||||||
| return $this->client->get('contacts', $options); | ||||||
|
|
@@ -57,7 +62,8 @@ public function getContacts(array $options = []) | |||||
| * @return stdClass | ||||||
| * @throws Exception | ||||||
| */ | ||||||
| public function getContact(string $id, array $options = []) | ||||||
|
|
||||||
| public function getContact($id, $options = []) | ||||||
|
||||||
| public function getContact($id, $options = []) | |
| public function getContact(string $id, array $options = []) |
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.
My bad. I think when I merged the change my version was included which wasn't typed. Fixed.
Outdated
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.
We should use camelCase for all variables in this repo 🙌
| * @param string $tag_id | |
| * @param string $tagId |
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.
WeCanCertainlyDoThat.
Fixed.
Outdated
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.
I think it would be cleaner if we create a contactTagsPath method in this class, what do you think?
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.
Good call, adding now.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,4 +19,45 @@ public function create($options) | |
| { | ||
| return $this->client->post("messages", $options); | ||
| } | ||
|
|
||
|
Contributor
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
Author
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.
I would prefer all the new methods to be strongly typed
Same for the rest of the methods in this file
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.
Fixed.