Skip to content

Commit 72ef109

Browse files
committed
Merge pull request #203 from intercom/RuairiK/bulk_api_readme
Add bulk API documentation to README
2 parents 1910189 + 5942bc8 commit 72ef109

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

README.md

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ Resources this API supports:
4949
https://api.intercom.io/conversations
5050
https://api.intercom.io/messages
5151
https://api.intercom.io/subscriptions
52+
https://api.intercom.io/jobs
53+
https://api.intercom.io/bulk
5254

5355
### Examples
5456

@@ -75,6 +77,14 @@ intercom.users.save(user)
7577
# Iterate over all users
7678
intercom.users.all.each {|user| puts %Q(#{user.email} - #{user.custom_attributes["average_monthly_spend"]}) }
7779
intercom.users.all.map {|user| user.email }
80+
81+
#Bulk operations. (BETA)
82+
# Submit bulk job, to create users
83+
intercom.users.submit_bulk_job(create_items: [{user_id: 25, email: "[email protected]"}, {user_id: 25, email: "[email protected]"}])
84+
# Submit bulk job, to delete users
85+
intercom.users.submit_bulk_job(delete_items: [{user_id: 25, email: "[email protected]"}, {user_id: 25, email: "[email protected]"}])
86+
# Submit bulk job, to add items to existing job
87+
intercom.users.submit_bulk_job(create_items: [{user_id: 25, email: "[email protected]"}], delete_items: [{user_id: 25, email: "[email protected]"}], job_id:'job_abcd1234')
7888
```
7989

8090
#### Admins
@@ -286,6 +296,8 @@ intercom.events.create(
286296
"found_date" => 12909364407
287297
}
288298
)
299+
300+
289301
```
290302

291303
Metadata Objects support a few simple types that Intercom can present on your behalf
@@ -316,6 +328,54 @@ The metadata key values in the example are treated as follows-
316328

317329
*NB:* This version of the gem reserves the field name `type` in Event data.
318330

331+
Bulk operations. (BETA)
332+
```ruby
333+
# Submit bulk job, to create events
334+
intercom.events.submit_bulk_job(create_items: [
335+
{
336+
event_name: "ordered-item",
337+
created_at: 1438944980,
338+
user_id: "314159",
339+
metadata: {
340+
order_date: 1438944980,
341+
stripe_invoice: "inv_3434343434"
342+
}
343+
},
344+
{
345+
event_name: "invited-friend",
346+
created_at: 1438944979,
347+
user_id: "314159",
348+
metadata: {
349+
invitee_email: "[email protected]",
350+
invite_code: "ADDAFRIEND"
351+
}
352+
}
353+
])
354+
355+
356+
# Submit bulk job, to add items to existing job
357+
intercom.events.submit_bulk_job(create_items: [
358+
{
359+
event_name: "ordered-item",
360+
created_at: 1438944980,
361+
user_id: "314159",
362+
metadata: {
363+
order_date: 1438944980,
364+
stripe_invoice: "inv_3434343434"
365+
}
366+
},
367+
{
368+
event_name: "invited-friend",
369+
created_at: 1438944979,
370+
user_id: "314159",
371+
metadata: {
372+
invitee_email: "[email protected]",
373+
invite_code: "ADDAFRIEND"
374+
}
375+
}
376+
], job_id:'job_abcd1234')
377+
```
378+
319379
### Contacts
320380

321381
`Contacts` represent logged out users of your application.
@@ -362,10 +422,19 @@ intercom.subscriptions.find(:id => "nsub_123456789")
362422
# list subscriptions
363423
intercom.subscriptions.all
364424
```
425+
### Bulk jobs (Beta)
426+
427+
```ruby
428+
# fetch a job
429+
intercom.jobs.find(id: 'job_abcd1234')
430+
431+
# fetch a job's error feed
432+
intercom.jobs.errors(id: 'job_abcd1234')
433+
```
365434

366435
### Errors
367436

368-
There are different styles for error handlng - some people prefer exceptions; some prefer nil and check; some prefer error objects/codes. Balancing these preferences alongside our wish to provide an idiomatic gem has brought us to use the current mechanism of throwing specific exceptions. Our approach in the client is to propagate errors and signal our failure loudly so that erroneous data does not get propagated through our customers' systems - in other words, if you see a `Intercom::ServiceUnavailableError` you know where the problem is.
437+
There are different styles for error handling - some people prefer exceptions; some prefer nil and check; some prefer error objects/codes. Balancing these preferences alongside our wish to provide an idiomatic gem has brought us to use the current mechanism of throwing specific exceptions. Our approach in the client is to propagate errors and signal our failure loudly so that erroneous data does not get propagated through our customers' systems - in other words, if you see a `Intercom::ServiceUnavailableError` you know where the problem is.
369438

370439
You do not need to deal with the HTTP response from an API call directly. If there is an unsuccessful response then an error that is a subclass of Intercom:Error will be raised. If desired, you can get at the http_code of an Intercom::Error via its `http_code` method.
371440

0 commit comments

Comments
 (0)