Skip to content

Commit 708e514

Browse files
authored
Styling fixes (#265)
* Fix readme examples styling * Fix code styling issues
1 parent a650486 commit 708e514

File tree

5 files changed

+115
-106
lines changed

5 files changed

+115
-106
lines changed

README.md

Lines changed: 94 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ $client = new IntercomClient('<insert_token_here>', null);
4848
```php
4949
/** Create a user */
5050
$client->users->create([
51-
"email" => "[email protected]",
52-
"custom_attributes" => ['foo' => 'bar']
51+
"email" => "[email protected]",
52+
"custom_attributes" => ['foo' => 'bar']
5353
]);
5454

5555
/**
5656
* Update a user (Note: This method is an alias to the create method. In practice you
5757
* can use create to update users if you wish)
5858
*/
5959
$client->users->update([
60-
"email" => "[email protected]",
61-
"custom_attributes" => ['foo' => 'bar']
60+
"email" => "[email protected]",
61+
"custom_attributes" => ['foo' => 'bar']
6262
]);
6363

6464
/** Delete a user by ID */
@@ -69,23 +69,23 @@ $client->users->getUser("570680a8a1bcbca8a90001b9");
6969

7070
/** Add companies to a user */
7171
$client->users->create([
72-
"email" => "[email protected]",
73-
"companies" => [
74-
[
75-
"company_id" => "3"
72+
"email" => "[email protected]",
73+
"companies" => [
74+
[
75+
"company_id" => "3"
76+
]
7677
]
77-
]
7878
]);
7979

8080
/** Remove companies from a user */
8181
$client->users->create([
82-
"email" => "[email protected]",
83-
"companies" => [
84-
[
85-
"company_id" => "3",
86-
"remove" => true
82+
"email" => "[email protected]",
83+
"companies" => [
84+
[
85+
"company_id" => "3",
86+
"remove" => true
87+
]
8788
]
88-
]
8989
]);
9090

9191
/** Find a single user by email */
@@ -113,17 +113,17 @@ See [here](https://github.com/intercom/intercom-php#scroll) for more info on usi
113113
* See more options here: https://developers.intercom.io/reference#create-lead
114114
*/
115115
$client->leads->create([
116-
"email" => "[email protected]",
117-
"custom_attributes" => ['foo' => 'bar']
116+
"email" => "[email protected]",
117+
"custom_attributes" => ['foo' => 'bar']
118118
]);
119119

120120
/**
121121
* Update a lead (Note: This method is an alias to the create method.
122122
* In practice you can use create to update leads if you wish)
123123
*/
124124
$client->leads->update([
125-
"email" => "[email protected]",
126-
"custom_attributes" => ['foo' => 'bar']
125+
"email" => "[email protected]",
126+
"custom_attributes" => ['foo' => 'bar']
127127
]);
128128

129129
/**
@@ -140,12 +140,12 @@ $client->leads->deleteLead("570680a8a1bcbca8a90000a9");
140140

141141
/** Convert a Lead to a User */
142142
$client->leads->convertLead([
143-
"contact" => [
144-
"user_id" => "8a88a590-e1c3-41e2-a502-e0649dbf721c"
145-
],
146-
"user" => [
147-
"email" => "[email protected]"
148-
]
143+
"contact" => [
144+
"user_id" => "8a88a590-e1c3-41e2-a502-e0649dbf721c"
145+
],
146+
"user" => [
147+
"email" => "[email protected]"
148+
]
149149
]);
150150

151151
/**
@@ -166,8 +166,8 @@ Retrieve `user_id` of a visitor via [the JavaScript API](https://developers.inte
166166
```php
167167
/** Update a visitor */
168168
$client->visitors->update([
169-
"user_id" => "8a88a590-e1c3-41e2-a502-e0649dbf721c",
170-
"custom_attributes" => ['foo' => 'bar']
169+
"user_id" => "8a88a590-e1c3-41e2-a502-e0649dbf721c",
170+
"custom_attributes" => ['foo' => 'bar']
171171
]);
172172

173173
/** Find a visitor by ID */
@@ -181,21 +181,21 @@ $client->visitors->deleteVisitor("570680a8a1bcbca8a90000a9");
181181

182182
/** Convert a Visitor to a Lead */
183183
$client->visitors->convertVisitor([
184-
"visitor" => [
185-
"user_id" => "8a88a590-e1c3-41e2-a502-e0649dbf721c"
186-
],
187-
"type" => "lead"
184+
"visitor" => [
185+
"user_id" => "8a88a590-e1c3-41e2-a502-e0649dbf721c"
186+
],
187+
"type" => "lead"
188188
]);
189189

190190
/** Convert a Visitor to a User */
191191
$client->visitors->convertVisitor([
192-
"visitor" => [
193-
"user_id" => "8a88a590-e1c3-41e2-a502-e0649dbf721c"
194-
],
195-
"user" => [
196-
"email" => "[email protected]"
197-
],
198-
"type" => "user"
192+
"visitor" => [
193+
"user_id" => "8a88a590-e1c3-41e2-a502-e0649dbf721c"
194+
],
195+
"user" => [
196+
"email" => "[email protected]"
197+
],
198+
"type" => "user"
199199
]);
200200
```
201201

@@ -210,10 +210,10 @@ $client->tags->getTags();
210210
* See more options here: https://developers.intercom.io/reference#tag-or-untag-users-companies-leads-contacts
211211
*/
212212
$client->tags->tag([
213-
"name" => "Test",
214-
"users" => [
215-
["id" => "1234"]
216-
]
213+
"name" => "Test",
214+
"users" => [
215+
["id" => "1234"]
216+
]
217217
]);
218218
```
219219

@@ -235,9 +235,9 @@ $client->segments->getSegment("59c124f770e00fd819b9ce81", ["include_count"=>"tru
235235
```php
236236
/** Create an event */
237237
$client->events->create([
238-
"event_name" => "testing",
239-
"created_at" => 1391691571,
240-
"email" => "[email protected]"
238+
"event_name" => "testing",
239+
"created_at" => 1391691571,
240+
"email" => "[email protected]"
241241
]);
242242

243243
/** View events for a user */
@@ -249,25 +249,27 @@ $client->events->getEvents(["email" => "[email protected]"]);
249249
```php
250250
/** Create a company */
251251
$client->companies->create([
252-
"name" => "foocorp", "company_id" => "3"
252+
"name" => "foocorp",
253+
"company_id" => "3"
253254
]);
254255

255256
/**
256257
* Update a company (Note: This method is an alias to the create method.
257258
* In practice you can use create to update companies if you wish)
258259
*/
259260
$client->companies->update([
260-
"name" => "foocorp", "id" => "3"
261+
"name" => "foocorp",
262+
"id" => "3"
261263
]);
262264

263265
/** Creating or Update a company with custom attributes. */
264266
$client->companies->update([
265-
"name" => "foocorp",
266-
"id" => "3",
267-
"custom_attributes" => [
268-
"foo" => "bar",
269-
"baz" => "qux"
270-
]
267+
"name" => "foocorp",
268+
"id" => "3",
269+
"custom_attributes" => [
270+
"foo" => "bar",
271+
"baz" => "qux"
272+
]
271273
]);
272274

273275
/** List Companies */
@@ -292,17 +294,17 @@ $client->admins->getAdmins();
292294
* See more options here: https://developers.intercom.io/reference#conversations
293295
*/
294296
$client->messages->create([
295-
"message_type" => "inapp",
296-
"subject" => "Hey",
297-
"body" => "Ponies, cute small horses or something more sinister?",
298-
"from" => [
299-
"type" => "admin",
300-
"id" => "1234"
301-
],
302-
"to" => [
303-
"type" => "user",
304-
"email" => "[email protected]"
305-
]
297+
"message_type" => "inapp",
298+
"subject" => "Hey",
299+
"body" => "Ponies, cute small horses or something more sinister?",
300+
"from" => [
301+
"type" => "admin",
302+
"id" => "1234"
303+
],
304+
"to" => [
305+
"type" => "user",
306+
"email" => "[email protected]"
307+
]
306308
]);
307309
```
308310

@@ -314,38 +316,38 @@ $client->messages->create([
314316
* See more options here: https://developers.intercom.io/reference#list-conversations
315317
*/
316318
$client->conversations->getConversations([
317-
"type" => "admin",
318-
"admin_id" => "25610"
319+
"type" => "admin",
320+
"admin_id" => "25610"
319321
]);
320322

321323
/** Get a single conversation */
322324
$client->conversations->getConversation("1234")
323325

324326
/** Get a single conversation with plaintext comments */
325327
$client->conversations->getConversation("1234", [
326-
"display_as" => "plaintext"
328+
"display_as" => "plaintext"
327329
])
328330

329331
/**
330332
* Reply to a conversation
331333
* See more options here: https://developers.intercom.io/reference#replying-to-a-conversation
332334
*/
333335
$client->conversations->replyToConversation("5678", [
334-
"email" => "[email protected]",
335-
"body" => "Thanks :)",
336-
"type" => "user",
337-
"message_type" => "comment"
336+
"email" => "[email protected]",
337+
"body" => "Thanks :)",
338+
"type" => "user",
339+
"message_type" => "comment"
338340
]);
339341

340342
/**
341343
* Reply to a user's last conversation
342344
* See more options here: https://developers.intercom.com/reference#replying-to-users-last-conversation
343345
*/
344346
$client->conversations->replyToLastConversation([
345-
"email" => "[email protected]",
346-
"body" => "Thanks :)",
347-
"type" => "user",
348-
"message_type" => "comment"
347+
"email" => "[email protected]",
348+
"body" => "Thanks :)",
349+
"type" => "user",
350+
"message_type" => "comment"
349351
]);
350352

351353
/**
@@ -370,11 +372,11 @@ $client->counts->getCounts([])
370372
```php
371373
/** Create a note */
372374
$client->notes->create([
373-
"admin_id" => "21",
374-
"body" => "Text for my note",
375-
"user" => [
376-
"id" => "5310d8e8598c9a0b24000005"
377-
]
375+
"admin_id" => "21",
376+
"body" => "Text for my note",
377+
"user" => [
378+
"id" => "5310d8e8598c9a0b24000005"
379+
]
378380
]);
379381

380382
/** List notes for a user */
@@ -428,23 +430,21 @@ For more information on scroll please see the [API reference](https://developers
428430
Here is an example of a simple way to use the scroll for multiple calls:
429431

430432
```php
431-
<?php
432433
require "vendor/autoload.php";
434+
433435
use Intercom\IntercomClient;
434436

435-
$intercom= new IntercomClient(getenv('AT'), null);
437+
$intercom = new IntercomClient(getenv('AT'), null);
436438
$resp = $intercom->users->scrollUsers([]);
437-
#var_dump($resp);
438439
$count = 1;
439440
echo "PAGE $count: " . sizeof($resp->users);
440441
echo "\n";
441-
while (!empty($resp->scroll_param && sizeof($resp->users) > 0)){
442+
while (!empty($resp->scroll_param) && sizeof($resp->users) > 0) {
442443
$count = ++$count;
443444
$resp = $intercom->users->scrollUsers(["scroll_param" => $resp->scroll_param]);
444445
echo "PAGE $count: " . sizeof($resp->users);
445446
echo "\n";
446447
}
447-
?>
448448
```
449449

450450
## Exceptions
@@ -457,16 +457,16 @@ If you want to catch errors you can wrap your API call into a try/catch:
457457
use GuzzleHttp\Exception\ClientException;
458458

459459
try {
460-
$user = $client->users->getUser("570680a8a1bcbca8a90001b9");
460+
$user = $client->users->getUser("570680a8a1bcbca8a90001b9");
461461
} catch(ClientException $e) {
462-
$response = $e->getResponse();
463-
$statusCode = $response->getStatusCode();
464-
if ($statusCode == '404') {
465-
// Handle 404 error
466-
return;
467-
} else {
468-
throw $e;
469-
}
462+
$response = $e->getResponse();
463+
$statusCode = $response->getStatusCode();
464+
if ($statusCode == '404') {
465+
// Handle 404 error
466+
return;
467+
} else {
468+
throw $e;
469+
}
470470
}
471471
```
472472

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
}
1616
},
1717
"require": {
18-
"guzzlehttp/guzzle": "~6.0",
19-
"php": ">= 5.6"
18+
"php": ">= 5.6",
19+
"ext-json": "*",
20+
"guzzlehttp/guzzle": "~6.0"
2021
},
2122
"require-dev": {
2223
"phpunit/phpunit": "4.0.*",

src/IntercomAdmins.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ public function getAdmin($id, $options = [])
4848
return $this->client->get($path, $options);
4949
}
5050

51+
/**
52+
* Returns endpoint path to Admin with given ID.
53+
*
54+
* @param string $id
55+
* @return string
56+
*/
5157
public function adminPath($id)
5258
{
5359
return 'admins/' . $id;

0 commit comments

Comments
 (0)