@@ -93,15 +93,15 @@ This resource is only available in API Versions 2.0 and above
93
93
``` php
94
94
/** Create a contact */
95
95
$client->contacts->create([
96
- 'type ' => 'user' ,
96
+ 'custom_attributes ' => ['nickname' => 'Teddy'] ,
97
97
98
- 'custom_attributes ' => ['foo' => 'bar']
98
+ 'type ' => 'user',
99
99
]);
100
100
101
101
/** Update a contact */
102
102
$client->contacts->update('570680a8a1bcbca8a90001b9', [
103
+ 'custom_attributes' => ['nickname' => 'Teddy'],
103
104
104
- 'custom_attributes' => ['foo' => 'bar']
105
105
]);
106
106
107
107
/** Permanently delete a contact */
@@ -113,9 +113,9 @@ $client->contacts->getContact('570680a8a1bcbca8a90001b9');
113
113
/** Search for contacts */
114
114
$query = ['field' => 'name', 'operator' => '=', 'value' => 'Alice'];
115
115
$client->contacts->search([
116
+ 'pagination' => ['per_page' => 10],
116
117
'query' => $query,
117
118
'sort' => ['field' => 'name', 'order' => 'ascending'],
118
- 'pagination' => ['per_page' => 10]
119
119
]);
120
120
121
121
/** Get next page of conversation search results */
@@ -132,17 +132,17 @@ This resource is only available in API Versions 1.0 to 1.4. Newer versions use t
132
132
``` php
133
133
/** Create a user */
134
134
$client->users->create([
135
+ 'custom_attributes' => ['nickname' => 'Teddy'],
135
136
136
- 'custom_attributes' => ['foo' => 'bar']
137
137
]);
138
138
139
139
/**
140
140
* Update a user (Note: This method is an alias to the create method. In practice you
141
141
* can use create to update users if you wish)
142
142
*/
143
143
$client->users->update([
144
+ 'custom_attributes' => ['nickname' => 'Teddy'],
144
145
145
- 'custom_attributes' => ['foo' => 'bar']
146
146
]);
147
147
148
148
/** Archive a user by ID (i.e. soft delete) */
@@ -158,27 +158,29 @@ $client->users->getUser('570680a8a1bcbca8a90001b9');
158
158
159
159
/** Add companies to a user */
160
160
$client->users->create([
161
-
162
161
'companies' => [
163
162
[
164
- 'company_id' => '3'
163
+ 'company_id' => '3',
165
164
]
166
- ]
165
+ ],
166
+
167
167
]);
168
168
169
169
/** Remove companies from a user */
170
170
$client->users->create([
171
-
172
171
'companies' => [
173
172
[
174
173
'company_id' => '3',
175
- 'remove' => true
174
+ 'remove' => true,
176
175
]
177
- ]
176
+ ],
177
+
178
178
]);
179
179
180
180
/** Find a single user by email */
181
- $client->users->getUsers(['email' => '
[email protected] ']);
181
+ $client->users->getUsers([
182
+
183
+ ]);
182
184
183
185
/** List all users up to 10k records */
184
186
$client->users->getUsers([]);
@@ -204,17 +206,17 @@ This resource is only available in API Versions 1.0 to 1.4. Newer versions use t
204
206
* See more options here: https://developers.intercom.io/reference#create-lead
205
207
*/
206
208
$client->leads->create([
209
+ 'custom_attributes' => ['nickname' => 'Teddy'],
207
210
208
- 'custom_attributes' => ['foo' => 'bar']
209
211
]);
210
212
211
213
/**
212
214
* Update a lead (Note: This method is an alias to the create method.
213
215
* In practice you can use create to update leads if you wish)
214
216
*/
215
217
$client->leads->update([
218
+ 'custom_attributes' => ['nickname' => 'Teddy'],
216
219
217
- 'custom_attributes' => ['foo' => 'bar']
218
220
]);
219
221
220
222
/**
@@ -232,11 +234,11 @@ $client->leads->deleteLead('570680a8a1bcbca8a90000a9');
232
234
/** Convert a Lead to a User */
233
235
$client->leads->convertLead([
234
236
'contact' => [
235
- 'user_id' => '8a88a590-e1c3-41e2-a502-e0649dbf721c'
237
+ 'user_id' => '8a88a590-e1c3-41e2-a502-e0649dbf721c',
236
238
],
237
239
'user' => [
238
-
239
- ]
240
+
241
+ ],
240
242
]);
241
243
242
244
/**
@@ -257,36 +259,38 @@ Retrieve `user_id` of a visitor via [the JavaScript API](https://developers.inte
257
259
``` php
258
260
/** Update a visitor */
259
261
$client->visitors->update([
262
+ 'custom_attributes' => ['nickname' => 'Teddy'],
260
263
'user_id' => '8a88a590-e1c3-41e2-a502-e0649dbf721c',
261
- 'custom_attributes' => ['foo' => 'bar']
262
264
]);
263
265
264
266
/** Find a visitor by ID */
265
267
$client->visitors->getVisitor('570680a8a1bcbca8a90000a9');
266
268
267
269
/** Find a visitor by User ID */
268
- $client->visitors->getVisitor('', ['user_id' => '8a88a590-e1c3-41e2-a502-e0649dbf721c']);
270
+ $client->visitors->getVisitor('', [
271
+ 'user_id' => '8a88a590-e1c3-41e2-a502-e0649dbf721c',
272
+ ]);
269
273
270
274
/** Delete a visitor by ID */
271
275
$client->visitors->deleteVisitor('570680a8a1bcbca8a90000a9');
272
276
273
277
/** Convert a Visitor to a Lead */
274
278
$client->visitors->convertVisitor([
279
+ 'type' => 'lead',
275
280
'visitor' => [
276
- 'user_id' => '8a88a590-e1c3-41e2-a502-e0649dbf721c'
281
+ 'user_id' => '8a88a590-e1c3-41e2-a502-e0649dbf721c',
277
282
],
278
- 'type' => 'lead'
279
283
]);
280
284
281
285
/** Convert a Visitor to a User */
282
286
$client->visitors->convertVisitor([
283
- 'visitor' => [
284
- 'user_id' => '8a88a590-e1c3-41e2-a502-e0649dbf721c'
285
- ],
287
+ 'type' => 'user',
286
288
'user' => [
287
-
289
+
290
+ ],
291
+ 'visitor' => [
292
+ 'user_id' => '8a88a590-e1c3-41e2-a502-e0649dbf721c',
288
293
],
289
- 'type' => 'user'
290
294
]);
291
295
```
292
296
@@ -303,8 +307,8 @@ $client->tags->getTags();
303
307
$client->tags->tag([
304
308
'name' => 'Test',
305
309
'users' => [
306
- ['id' => '1234']
307
- ]
310
+ ['id' => '1234'],
311
+ ],
308
312
]);
309
313
```
310
314
@@ -318,21 +322,23 @@ $client->segments->getSegments();
318
322
$client->segments->getSegment('58a707924f6651b07b94376c');
319
323
320
324
/** View a segment with count */
321
- $client->segments->getSegment('59c124f770e00fd819b9ce81', ['include_count' => 'true']);
325
+ $client->segments->getSegment('59c124f770e00fd819b9ce81', [
326
+ 'include_count' => 'true',
327
+ ]);
322
328
```
323
329
324
330
## Events
325
331
326
332
``` php
327
333
/** Create an event */
328
334
$client->events->create([
329
- 'event_name' => 'testing',
330
335
'created_at' => 1391691571,
331
336
337
+ 'event_name' => 'testing',
332
338
'metadata' => [
333
339
'order_date' => 1392036272,
334
- 'stripe_invoice' => 'inv_3434343434'
335
- ]
340
+ 'stripe_invoice' => 'inv_3434343434',
341
+ ],
336
342
]);
337
343
338
344
/** View events for a user */
344
350
``` php
345
351
/** Create a company */
346
352
$client->companies->create([
353
+ 'company_id' => '3',
347
354
'name' => 'foocorp',
348
- 'company_id' => '3'
349
355
]);
350
356
351
357
/**
352
358
* Update a company
353
359
*/
354
360
$client->companies->update([
361
+ 'id' => '3',
355
362
'name' => 'foocorp',
356
- 'id' => '3'
357
363
]);
358
364
359
365
/** Create or update a company with custom attributes. */
360
366
$client->companies->update([
361
- 'name' => 'foocorp',
362
- 'id' => '3',
363
367
'custom_attributes' => [
364
- 'foo' => 'bar',
365
- 'baz' => 'qux'
366
- ]
368
+ 'short_name' => 'ABC Inc.',
369
+ ],
370
+ 'id' => '3',
371
+ 'name' => 'foocorp',
367
372
]);
368
373
369
374
/** List Companies */
@@ -376,7 +381,10 @@ $client->companies->getCompany('531ee472cce572a6ec000006');
376
381
$client->companies->getCompanyUsers('531ee472cce572a6ec000006');
377
382
378
383
/** List users belonging to a company by company_id */
379
- $client->companies->getCompanies(['type' => 'user', 'company_id' => '3']);
384
+ $client->companies->getCompanies([
385
+ 'company_id' => '3',
386
+ 'type' => 'user',
387
+ ]);
380
388
381
389
/**
382
390
* Add companies to a contact with IDs
@@ -407,17 +415,17 @@ $client->admins->getAdmins();
407
415
* See more options here: https://developers.intercom.io/reference#conversations
408
416
*/
409
417
$client->messages->create([
410
- 'message_type' => 'inapp',
411
- 'subject' => 'Hey',
412
418
'body' => 'Ponies, cute small horses or something more sinister?',
413
419
'from' => [
420
+ 'id' => '1234',
414
421
'type' => 'admin',
415
- 'id' => '1234'
416
422
],
423
+ 'message_type' => 'inapp',
424
+ 'subject' => 'Hey',
417
425
'to' => [
426
+
418
427
'type' => 'user',
419
-
420
- ]
428
+ ],
421
429
]);
422
430
```
423
431
@@ -429,24 +437,24 @@ $client->messages->create([
429
437
* See more options here: https://developers.intercom.io/reference#list-conversations
430
438
*/
431
439
$client->conversations->getConversations([
440
+ 'admin_id' => '25610',
432
441
'type' => 'admin',
433
- 'admin_id' => '25610'
434
442
]);
435
443
436
444
/** Get a single conversation */
437
- $client->conversations->getConversation('1234')
445
+ $client->conversations->getConversation('1234');
438
446
439
447
/** Get a single conversation with plaintext comments */
440
448
$client->conversations->getConversation('1234', [
441
- 'display_as' => 'plaintext'
442
- ])
449
+ 'display_as' => 'plaintext',
450
+ ]);
443
451
444
452
/** Search for conversations (API version >= 2.0) */
445
453
$query = ['field' => 'updated_at', 'operator' => '>', 'value' => '1560436784'];
446
454
$client->conversations->search([
455
+ 'pagination' => ['per_page' => 10],
447
456
'query' => $query,
448
457
'sort' => ['field' => 'updated_at', 'order' => 'ascending'],
449
- 'pagination' => ['per_page' => 10]
450
458
]);
451
459
452
460
/** Get next page of conversation search results (API version >= 2.0) */
@@ -457,21 +465,21 @@ $client->conversations->nextSearch($query, $response->pages);
457
465
* See more options here: https://developers.intercom.io/reference#replying-to-a-conversation
458
466
*/
459
467
$client->conversations->replyToConversation('5678', [
460
-
461
468
'body' => 'Thanks :)',
469
+
470
+ 'message_type' => 'comment',
462
471
'type' => 'user',
463
- 'message_type' => 'comment'
464
472
]);
465
473
466
474
/**
467
475
* Reply to a user's last conversation
468
476
* See more options here: https://developers.intercom.com/reference#replying-to-users-last-conversation
469
477
*/
470
478
$client->conversations->replyToLastConversation([
471
-
472
479
'body' => 'Thanks :)',
480
+
481
+ 'message_type' => 'comment',
473
482
'type' => 'user',
474
- 'message_type' => 'comment'
475
483
]);
476
484
477
485
/**
@@ -488,7 +496,7 @@ $client->conversations->markConversationAsRead('7890');
488
496
* List counts
489
497
* See more options here: https://developers.intercom.io/reference#getting-counts
490
498
*/
491
- $client->counts->getCounts([])
499
+ $client->counts->getCounts([]);
492
500
```
493
501
494
502
## Notes
@@ -499,13 +507,13 @@ $client->notes->create([
499
507
'admin_id' => '21',
500
508
'body' => 'Text for my note',
501
509
'user' => [
502
- 'id' => '5310d8e8598c9a0b24000005'
510
+ 'id' => '5310d8e8598c9a0b24000005',
503
511
]
504
512
]);
505
513
506
514
/** List notes for a user */
507
515
$client->notes->getNotes([
508
- 'user_id' => '25'
516
+ 'user_id' => '25',
509
517
]);
510
518
511
519
/** Get a single Note by id */
@@ -522,7 +530,6 @@ $client->teams->getTeams();
522
530
$client->teams->getTeam('1188');
523
531
```
524
532
525
-
526
533
## Rate Limits
527
534
528
535
Rate limit info is passed via the rate limit headers.
0 commit comments