Skip to content

Commit a722f7f

Browse files
committed
Added PhpDoc to methods and variables
1 parent 0ab8dd4 commit a722f7f

12 files changed

+268
-22
lines changed

src/IntercomAdmins.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,26 @@
22

33
namespace Intercom;
44

5-
use GuzzleHttp\Client;
6-
75
class IntercomAdmins {
6+
7+
/** @var IntercomClient */
88
private $client;
99

10+
/**
11+
* IntercomAdmins constructor.
12+
* @param IntercomClient $client
13+
*/
1014
public function __construct($client)
1115
{
1216
$this->client = $client;
1317
}
1418

19+
/**
20+
* Returns list of Admins.
21+
* @see https://developers.intercom.io/reference#list-admins
22+
* @param array $options
23+
* @return mixed
24+
*/
1525
public function getAdmins($options = [])
1626
{
1727
return $this->client->get("admins", $options);

src/IntercomBulk.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,37 @@
22

33
namespace Intercom;
44

5-
use GuzzleHttp\Client;
6-
75
class IntercomBulk {
6+
7+
/** @var IntercomClient */
88
private $client;
99

10+
/**
11+
* IntercomBulk constructor.
12+
* @param IntercomClient $client
13+
*/
1014
public function __construct($client)
1115
{
1216
$this->client = $client;
1317
}
1418

19+
/**
20+
* Creates Users in bulk.
21+
* @see https://developers.intercom.io/reference#bulk-user-operations
22+
* @param array $options
23+
* @return mixed
24+
*/
1525
public function users($options)
1626
{
1727
return $this->client->post("bulk/users", $options);
1828
}
1929

30+
/**
31+
* Creates Events in bulk.
32+
* @see https://developers.intercom.io/reference#bulk-event-operations
33+
* @param array $options
34+
* @return mixed
35+
*/
2036
public function events($options)
2137
{
2238
return $this->client->post("bulk/events", $options);

src/IntercomClient.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use GuzzleHttp\Client;
66
use GuzzleHttp\Psr7\Response;
77
use function GuzzleHttp\Psr7\stream_for;
8+
use Psr\Http\Message\ResponseInterface;
89

910
class IntercomClient {
1011

@@ -47,6 +48,11 @@ class IntercomClient {
4748
/** @var IntercomBulk $bulk */
4849
public $bulk;
4950

51+
/**
52+
* IntercomClient constructor.
53+
* @param string $usernamePart App ID.
54+
* @param string $passwordPart Api Key.
55+
*/
5056
public function __construct($usernamePart, $passwordPart)
5157
{
5258
$this->setDefaultClient();
@@ -70,11 +76,21 @@ private function setDefaultClient()
7076
$this->http_client = new Client();
7177
}
7278

79+
/**
80+
* Sets GuzzleHttp client.
81+
* @param Client $client
82+
*/
7383
public function setClient($client)
7484
{
7585
$this->http_client = $client;
7686
}
7787

88+
/**
89+
* Sends POST request to Intercom API.
90+
* @param string $endpoint
91+
* @param string $json
92+
* @return mixed
93+
*/
7894
public function post($endpoint, $json)
7995
{
8096
$response = $this->http_client->request('POST', "https://api.intercom.io/$endpoint", [
@@ -87,6 +103,12 @@ public function post($endpoint, $json)
87103
return $this->handleResponse($response);
88104
}
89105

106+
/**
107+
* Sends DELETE request to Intercom API.
108+
* @param string $endpoint
109+
* @param string $json
110+
* @return mixed
111+
*/
90112
public function delete($endpoint, $json)
91113
{
92114
$response = $this->http_client->request('DELETE', "https://api.intercom.io/$endpoint", [
@@ -99,6 +121,11 @@ public function delete($endpoint, $json)
99121
return $this->handleResponse($response);
100122
}
101123

124+
/**
125+
* @param string $endpoint
126+
* @param string $query
127+
* @return mixed
128+
*/
102129
public function get($endpoint, $query)
103130
{
104131
$response = $this->http_client->request('GET', "https://api.intercom.io/$endpoint", [
@@ -111,6 +138,11 @@ public function get($endpoint, $query)
111138
return $this->handleResponse($response);
112139
}
113140

141+
/**
142+
* Returns next page of the result.
143+
* @param array $pages
144+
* @return mixed
145+
*/
114146
public function nextPage($pages)
115147
{
116148
$response = $this->http_client->request('GET', $pages['next'], [
@@ -122,11 +154,19 @@ public function nextPage($pages)
122154
return $this->handleResponse($response);
123155
}
124156

157+
/**
158+
* Returns authentication parameters.
159+
* @return array
160+
*/
125161
public function getAuth()
126162
{
127163
return [$this->usernamePart, $this->passwordPart];
128164
}
129165

166+
/**
167+
* @param Response $response
168+
* @return mixed
169+
*/
130170
private function handleResponse(Response $response){
131171
$stream = stream_for($response->getBody());
132172
$data = json_decode($stream->getContents());

src/IntercomCompanies.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,37 @@
22

33
namespace Intercom;
44

5-
use GuzzleHttp\Client;
6-
75
class IntercomCompanies {
6+
7+
/** @var IntercomClient */
88
private $client;
99

10+
/**
11+
* IntercomCompanies constructor.
12+
* @param IntercomClient $client
13+
*/
1014
public function __construct($client)
1115
{
1216
$this->client = $client;
1317
}
1418

19+
/**
20+
* Creates a Company.
21+
* @see https://developers.intercom.io/reference#create-or-update-company
22+
* @param array $options
23+
* @return mixed
24+
*/
1525
public function create($options)
1626
{
1727
return $this->client->post("companies", $options);
1828
}
1929

30+
/**
31+
* Returns list of Companies.
32+
* @see https://developers.intercom.io/reference#list-companies
33+
* @param array $options
34+
* @return mixed
35+
*/
2036
public function getCompanies($options)
2137
{
2238
return $this->client->get("companies", $options);

src/IntercomConversations.php

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,69 @@
22

33
namespace Intercom;
44

5-
use GuzzleHttp\Client;
6-
75
class IntercomConversations {
6+
7+
/** @var IntercomClient */
88
private $client;
99

10+
/**
11+
* IntercomConversations constructor.
12+
* @param IntercomClient $client
13+
*/
1014
public function __construct($client)
1115
{
1216
$this->client = $client;
1317
}
1418

19+
/**
20+
* Returns list of Conversations.
21+
* @see https://developers.intercom.io/reference#list-conversations
22+
* @param array $options
23+
* @return mixed
24+
*/
1525
public function getConversations($options)
1626
{
1727
return $this->client->get("conversations", $options);
1828
}
1929

30+
/**
31+
* Returns single Conversation.
32+
* @see https://developers.intercom.io/reference#get-a-single-conversation
33+
* @param string $id
34+
* @return mixed
35+
*/
2036
public function getConversation($id) {
2137
$path = $this->conversationPath($id);
2238
return $this->client->get($path, []);
2339
}
2440

41+
/**
42+
* Creates Conversation Reply to Conversation with given ID.
43+
* @see https://developers.intercom.io/reference#replying-to-a-conversation
44+
* @param string $id
45+
* @param array $options
46+
* @return mixed
47+
*/
2548
public function replyToConversation($id, $options) {
2649
$path = $this->conversationReplyPath($id);
2750
return $this->client->post($path, $options);
2851
}
2952

53+
/**
54+
* Returns endpoint path to Conversation with given ID.
55+
* @param string $id
56+
* @return string
57+
*/
3058
public function conversationPath($id)
3159
{
3260
return "conversations/" . $id;
3361
}
3462

63+
/**
64+
* Returns endpoint path to Conversation Reply for Conversation with given ID.
65+
* @param string $id
66+
* @return string
67+
*/
3568
public function conversationReplyPath($id)
3669
{
3770
return "conversations/" . $id . "/reply";

src/IntercomCounts.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,26 @@
22

33
namespace Intercom;
44

5-
use GuzzleHttp\Client;
6-
75
class IntercomCounts {
6+
7+
/** @var IntercomClient */
88
private $client;
99

10+
/**
11+
* IntercomCounts constructor.
12+
* @param IntercomClient $client
13+
*/
1014
public function __construct($client)
1115
{
1216
$this->client = $client;
1317
}
1418

19+
/**
20+
* Returns list of Counts.
21+
* @see https://developers.intercom.io/reference#getting-counts
22+
* @param array $options
23+
* @return mixed
24+
*/
1525
public function getCounts($options = [])
1626
{
1727
return $this->client->get("counts", $options);

src/IntercomEvents.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,37 @@
22

33
namespace Intercom;
44

5-
use GuzzleHttp\Client;
6-
75
class IntercomEvents {
6+
7+
/** @var IntercomClient */
88
private $client;
99

10+
/**
11+
* IntercomEvents constructor.
12+
* @param IntercomClient $client
13+
*/
1014
public function __construct($client)
1115
{
1216
$this->client = $client;
1317
}
1418

19+
/**
20+
* Creates Event.
21+
* @see https://developers.intercom.io/reference#submitting-events
22+
* @param array $options
23+
* @return mixed
24+
*/
1525
public function create($options)
1626
{
1727
return $this->client->post("events", $options);
1828
}
1929

30+
/**
31+
* Lists User Events.
32+
* @see https://developers.intercom.io/reference#list-user-events
33+
* @param array $options
34+
* @return mixed
35+
*/
2036
public function getEvents($options)
2137
{
2238
return $this->client->get("events", array_merge(["type" => "user"], $options));

0 commit comments

Comments
 (0)