intercom 3.5.9 → 3.5.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +92 -94
- data/intercom.gemspec +1 -1
- data/lib/intercom.rb +0 -1
- data/lib/intercom/api_operations/bulk/submit.rb +2 -0
- data/lib/intercom/api_operations/delete.rb +1 -1
- data/lib/intercom/api_operations/find.rb +2 -0
- data/lib/intercom/api_operations/find_all.rb +1 -0
- data/lib/intercom/api_operations/list.rb +1 -0
- data/lib/intercom/api_operations/load.rb +2 -0
- data/lib/intercom/api_operations/save.rb +2 -1
- data/lib/intercom/api_operations/scroll.rb +2 -1
- data/lib/intercom/client_collection_proxy.rb +0 -1
- data/lib/intercom/extended_api_operations/segments.rb +1 -1
- data/lib/intercom/extended_api_operations/tags.rb +1 -1
- data/lib/intercom/extended_api_operations/users.rb +2 -1
- data/lib/intercom/lib/typed_json_deserializer.rb +2 -1
- data/lib/intercom/scroll_collection_proxy.rb +1 -2
- data/lib/intercom/service/conversation.rb +1 -0
- data/lib/intercom/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f98bf7f9725ad035949ca88859ba807a6323a83
|
4
|
+
data.tar.gz: 97e46a4507500d311495e11114fb80d0715cb0a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c83c5d9c5ad9d4844b5b8f7c3602e6bf76cbbb9e9836b264acbdcfdb5e3567310c1441e23c7cd0b2dac30f0200bbea46175fe9eea5c130aa49d16e9ca5cd2d4
|
7
|
+
data.tar.gz: b480c171fd98135e719c37be86b0d13f7288f65130583d863afad3dd32acdc42de3e66be8941620047ba57db9fc54548b10307cbed55bd5278563825e6728de0
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Ruby bindings for the Intercom API (https://developers.intercom.io/reference).
|
|
6
6
|
|
7
7
|
[Gem Documentation](http://rubydoc.info/github/intercom/intercom-ruby/master/frames)
|
8
8
|
|
9
|
-
For generating Intercom javascript script tags for Rails, please see https://github.com/intercom/intercom-rails
|
9
|
+
For generating Intercom javascript script tags for Rails, please see https://github.com/intercom/intercom-rails.
|
10
10
|
|
11
11
|
## Upgrading information
|
12
12
|
|
@@ -22,18 +22,13 @@ This version of the gem is compatible with `Ruby 2.1` and above.
|
|
22
22
|
|
23
23
|
Using bundler:
|
24
24
|
|
25
|
-
gem 'intercom',
|
25
|
+
gem 'intercom', '~> 3.5.9'
|
26
26
|
|
27
27
|
## Basic Usage
|
28
28
|
|
29
29
|
### Configure your client
|
30
30
|
|
31
|
-
|
32
|
-
intercom = Intercom::Client.new(app_id: 'my_app_id', api_key: 'my_api_key')
|
33
|
-
```
|
34
|
-
> Warning: API Keys are being deprecated - you should use a [personal access token](https://app.intercom.io/a/apps/_/settings/personal-access-token) instead. [Learn more](https://developers.intercom.io/docs/personal-access-tokens) about API Keys deprecation
|
35
|
-
|
36
|
-
You can get your `app_id` from the URL when you're logged into Intercom (it's the alphanumeric just after `/apps/`) and your API key from the API keys integration settings page (under your app settings - integrations in Intercom).
|
31
|
+
> If you already have a personal access token you can find it [here](https://app.intercom.io/a/apps/_/settings/personal-access-token). If you want to create or learn more about personal access tokens then you can find more info [here](https://developers.intercom.io/docs/personal-access-tokens).
|
37
32
|
|
38
33
|
```ruby
|
39
34
|
# With an OAuth or Personal Access token:
|
@@ -67,15 +62,15 @@ Resources this API supports:
|
|
67
62
|
|
68
63
|
```ruby
|
69
64
|
# Find user by email
|
70
|
-
user = intercom.users.find(:
|
65
|
+
user = intercom.users.find(email: "bob@example.com")
|
71
66
|
# Find user by user_id
|
72
|
-
user = intercom.users.find(:
|
67
|
+
user = intercom.users.find(user_id: "1")
|
73
68
|
# Find user by id
|
74
|
-
user = intercom.users.find(:
|
69
|
+
user = intercom.users.find(id: "1")
|
75
70
|
# Create a user
|
76
|
-
user = intercom.users.create(:
|
71
|
+
user = intercom.users.create(email: "bob@example.com", name: "Bob Smith", signed_up_at: Time.now.to_i)
|
77
72
|
# Delete a user
|
78
|
-
user = intercom.users.find(:
|
73
|
+
user = intercom.users.find(id: "1")
|
79
74
|
deleted_user = intercom.users.delete(user)
|
80
75
|
# Update custom_attributes for a user
|
81
76
|
user.custom_attributes["average_monthly_spend"] = 1234.56
|
@@ -104,17 +99,17 @@ result = intercom.users.scroll.next
|
|
104
99
|
# make a new request
|
105
100
|
result.scroll_param
|
106
101
|
=> "0730e341-63ef-44da-ab9c-9113f886326d"
|
107
|
-
result =
|
102
|
+
result = intercom.users.scroll.next("0730e341-63ef-44da-ab9c-9113f886326d");
|
108
103
|
|
109
104
|
#Bulk operations.
|
110
105
|
# Submit bulk job to create users. If any of the items in create_items match an existing user that user will be updated
|
111
|
-
intercom.users.submit_bulk_job(create_items: [{user_id: 25, email: "alice@example.com"}, {user_id: 25, email: "bob@example.com"}])
|
106
|
+
intercom.users.submit_bulk_job(create_items: [{user_id: "25", email: "alice@example.com"}, {user_id: "25", email: "bob@example.com"}])
|
112
107
|
# Submit bulk job to create users with companies. Companies must be sent as an array of objects nested within each applicable user object
|
113
|
-
intercom.users.submit_bulk_job(create_items: [{user_id: 25, email: "alice@example.com", companies: [{:
|
108
|
+
intercom.users.submit_bulk_job(create_items: [{user_id: "25", email: "alice@example.com", companies: [{company_id: 9, name: "Test Company"}]}])
|
114
109
|
# Submit bulk job, to delete users
|
115
|
-
intercom.users.submit_bulk_job(delete_items: [{user_id: 25, email: "alice@example.com"}, {user_id: 25, email: "bob@example.com"}])
|
110
|
+
intercom.users.submit_bulk_job(delete_items: [{user_id: "25", email: "alice@example.com"}, {user_id: "25", email: "bob@example.com"}])
|
116
111
|
# Submit bulk job, to add items to existing job
|
117
|
-
intercom.users.submit_bulk_job(create_items: [{user_id: 25, email: "alice@example.com"}], delete_items: [{user_id: 25, email: "bob@example.com"}], job_id:'job_abcd1234')
|
112
|
+
intercom.users.submit_bulk_job(create_items: [{user_id: "25", email: "alice@example.com"}], delete_items: [{user_id: "25", email: "bob@example.com"}], job_id:'job_abcd1234')
|
118
113
|
```
|
119
114
|
|
120
115
|
#### Admins
|
@@ -122,7 +117,7 @@ intercom.users.submit_bulk_job(create_items: [{user_id: 25, email: "alice@exampl
|
|
122
117
|
# Find access token owner (only with Personal Access Token and OAuth)
|
123
118
|
intercom.admins.me
|
124
119
|
# Find an admin by id
|
125
|
-
intercom.admins.find(:
|
120
|
+
intercom.admins.find(id: admin_id)
|
126
121
|
# Iterate over all admins
|
127
122
|
intercom.admins.all.each {|admin| puts admin.email }
|
128
123
|
```
|
@@ -130,18 +125,18 @@ intercom.admins.all.each {|admin| puts admin.email }
|
|
130
125
|
#### Companies
|
131
126
|
```ruby
|
132
127
|
# Add a user to one or more companies
|
133
|
-
user = intercom.users.find(:
|
134
|
-
user.companies = [{:
|
128
|
+
user = intercom.users.find(email: "bob@example.com")
|
129
|
+
user.companies = [{company_id: 6, name: "Intercom"}, {company_id: 9, name: "Test Company"}]
|
135
130
|
intercom.users.save(user)
|
136
131
|
# You can also pass custom attributes within a company as you do this
|
137
|
-
user.companies = [{:
|
132
|
+
user.companies = [{id: 6, name: "Intercom", custom_attributes: {referral_source: "Google"} } ]
|
138
133
|
intercom.users.save(user)
|
139
134
|
# Find a company by company_id
|
140
|
-
company = intercom.companies.find(:
|
135
|
+
company = intercom.companies.find(company_id: "44")
|
141
136
|
# Find a company by name
|
142
|
-
company = intercom.companies.find(:
|
137
|
+
company = intercom.companies.find(name: "Some company")
|
143
138
|
# Find a company by id
|
144
|
-
company = intercom.companies.find(:
|
139
|
+
company = intercom.companies.find(id: "41e66f0313708347cb0000d0")
|
145
140
|
# Update a company
|
146
141
|
company.name = 'Updated company name'
|
147
142
|
intercom.companies.save(company)
|
@@ -168,7 +163,7 @@ tag = intercom.tags.tag(name: 'blue', companies: [{id: "42ea2f1b93891f6a99000427
|
|
168
163
|
#### Segments
|
169
164
|
```ruby
|
170
165
|
# Find a segment
|
171
|
-
segment = intercom.segments.find(:
|
166
|
+
segment = intercom.segments.find(id: segment_id)
|
172
167
|
# Iterate over all segments
|
173
168
|
intercom.segments.all.each {|segment| puts "id: #{segment.id} name: #{segment.name}"}
|
174
169
|
```
|
@@ -176,37 +171,37 @@ intercom.segments.all.each {|segment| puts "id: #{segment.id} name: #{segment.na
|
|
176
171
|
#### Notes
|
177
172
|
```ruby
|
178
173
|
# Find a note by id
|
179
|
-
note = intercom.notes.find(:
|
174
|
+
note = intercom.notes.find(id: note)
|
180
175
|
# Create a note for a user
|
181
|
-
note = intercom.notes.create(:
|
176
|
+
note = intercom.notes.create(body: "<p>Text for the note</p>", email: 'joe@example.com')
|
182
177
|
# Iterate over all notes for a user via their email address
|
183
|
-
intercom.notes.find_all(:
|
178
|
+
intercom.notes.find_all(email: 'joe@example.com').each {|note| puts note.body}
|
184
179
|
# Iterate over all notes for a user via their user_id
|
185
|
-
intercom.notes.find_all(:
|
180
|
+
intercom.notes.find_all(user_id: '123').each {|note| puts note.body}
|
186
181
|
```
|
187
182
|
|
188
183
|
#### Conversations
|
189
184
|
```ruby
|
190
185
|
# FINDING CONVERSATIONS FOR AN ADMIN
|
191
186
|
# Iterate over all conversations (open and closed) assigned to an admin
|
192
|
-
intercom.conversations.find_all(:
|
187
|
+
intercom.conversations.find_all(type: 'admin', id: '7').each {|convo| ... }
|
193
188
|
# Iterate over all open conversations assigned to an admin
|
194
|
-
intercom.conversations.find_all(:
|
189
|
+
intercom.conversations.find_all(type: 'admin', id: 7, open: true).each {|convo| ... }
|
195
190
|
# Iterate over closed conversations assigned to an admin
|
196
|
-
intercom.conversations.find_all(:
|
191
|
+
intercom.conversations.find_all(type: 'admin', id: 7, open: false).each {|convo| ... }
|
197
192
|
# Iterate over closed conversations for assigned an admin, before a certain moment in time
|
198
|
-
intercom.conversations.find_all(:
|
193
|
+
intercom.conversations.find_all(type: 'admin', id: 7, open: false, before: 1374844930).each {|convo| ... }
|
199
194
|
|
200
195
|
# FINDING CONVERSATIONS FOR A USER
|
201
196
|
# Iterate over all conversations (read + unread, correct) with a user based on the users email
|
202
|
-
intercom.conversations.find_all(:
|
197
|
+
intercom.conversations.find_all(email: 'joe@example.com', type: 'user').each {|convo| ... }
|
203
198
|
# Iterate over through all conversations (read + unread) with a user based on the users email
|
204
|
-
intercom.conversations.find_all(:
|
199
|
+
intercom.conversations.find_all(email: 'joe@example.com', type: 'user', unread: false).each {|convo| ... }
|
205
200
|
# Iterate over all unread conversations with a user based on the users email
|
206
|
-
intercom.conversations.find_all(:
|
201
|
+
intercom.conversations.find_all(email: 'joe@example.com', type: 'user', unread: true).each {|convo| ... }
|
207
202
|
|
208
203
|
# FINDING A SINGLE CONVERSATION
|
209
|
-
conversation = intercom.conversations.find(:
|
204
|
+
conversation = intercom.conversations.find(id: '1')
|
210
205
|
|
211
206
|
# INTERACTING WITH THE PARTS OF A CONVERSATION
|
212
207
|
# Getting the subject of a part (only applies to email-based conversations)
|
@@ -218,11 +213,11 @@ conversation.conversation_parts[1].body
|
|
218
213
|
|
219
214
|
# REPLYING TO CONVERSATIONS
|
220
215
|
# User (identified by email) replies with a comment
|
221
|
-
intercom.conversations.reply(:
|
216
|
+
intercom.conversations.reply(id: conversation.id, type: 'user', email: 'joe@example.com', message_type: 'comment', body: 'foo')
|
222
217
|
# Admin (identified by id) replies with a comment
|
223
|
-
intercom.conversations.reply(:
|
218
|
+
intercom.conversations.reply(id: conversation.id, type: 'admin', admin_id: '123', message_type: 'comment', body: 'bar')
|
224
219
|
# User (identified by email) replies with a comment and attachment
|
225
|
-
intercom.conversations.reply(:
|
220
|
+
intercom.conversations.reply(id: conversation.id, type: 'user', email: 'joe@example.com', message_type: 'comment', body: 'foo', attachment_urls: ['http://www.example.com/attachment.jpg'])
|
226
221
|
|
227
222
|
# Open
|
228
223
|
intercom.conversations.open(id: conversation.id, admin_id: '123')
|
@@ -234,13 +229,13 @@ intercom.conversations.close(id: conversation.id, admin_id: '123')
|
|
234
229
|
intercom.conversations.assign(id: conversation.id, admin_id: '123', assignee_id: '124')
|
235
230
|
|
236
231
|
# Reply and Open
|
237
|
-
intercom.conversations.reply(:
|
232
|
+
intercom.conversations.reply(id: conversation.id, type: 'admin', admin_id: '123', message_type: 'open', body: 'bar')
|
238
233
|
|
239
234
|
# Reply and Close
|
240
|
-
intercom.conversations.reply(:
|
235
|
+
intercom.conversations.reply(id: conversation.id, type: 'admin', admin_id: '123', message_type: 'close', body: 'bar')
|
241
236
|
|
242
237
|
# ASSIGNING CONVERSATIONS TO ADMINS
|
243
|
-
intercom.conversations.reply(:
|
238
|
+
intercom.conversations.reply(id: conversation.id, type: 'admin', assignee_id: assignee_admin.id, admin_id: admin.id, message_type: 'assignment')
|
244
239
|
|
245
240
|
# MARKING A CONVERSATION AS READ
|
246
241
|
intercom.conversations.mark_read(conversation.id)
|
@@ -258,75 +253,76 @@ intercom.users.load(conversation.user)
|
|
258
253
|
|
259
254
|
# InApp message from admin to user
|
260
255
|
intercom.messages.create({
|
261
|
-
:
|
262
|
-
:
|
263
|
-
:
|
264
|
-
:
|
265
|
-
:
|
256
|
+
message_type: 'inapp',
|
257
|
+
body: "What's up :)",
|
258
|
+
from: {
|
259
|
+
type: 'admin',
|
260
|
+
id: "1234"
|
266
261
|
},
|
267
|
-
:
|
268
|
-
:
|
269
|
-
:
|
262
|
+
to: {
|
263
|
+
type: "user",
|
264
|
+
user_id: "5678"
|
270
265
|
}
|
271
266
|
})
|
272
267
|
|
273
268
|
# Email message from admin to user
|
274
269
|
intercom.messages.create({
|
275
|
-
:
|
276
|
-
:
|
277
|
-
:
|
278
|
-
:
|
279
|
-
:
|
280
|
-
:
|
281
|
-
:
|
270
|
+
message_type: 'email',
|
271
|
+
subject: 'Hey there',
|
272
|
+
body: "What's up :)",
|
273
|
+
template: "plain", # or "personal",
|
274
|
+
from: {
|
275
|
+
type: "admin",
|
276
|
+
id: "1234"
|
282
277
|
},
|
283
|
-
:
|
284
|
-
:
|
285
|
-
:
|
278
|
+
to: {
|
279
|
+
type: "user",
|
280
|
+
id: "536e564f316c83104c000020"
|
286
281
|
}
|
287
282
|
})
|
288
283
|
|
289
284
|
# Message from a user
|
290
285
|
intercom.messages.create({
|
291
|
-
:
|
292
|
-
:
|
293
|
-
:
|
286
|
+
from: {
|
287
|
+
type: "user",
|
288
|
+
id: "536e564f316c83104c000020"
|
294
289
|
},
|
295
|
-
:
|
290
|
+
body: "halp"
|
296
291
|
})
|
297
292
|
|
298
293
|
# Message from admin to contact
|
299
294
|
|
300
295
|
intercom.messages.create({
|
301
|
-
:
|
302
|
-
:
|
303
|
-
:
|
304
|
-
:
|
296
|
+
body: "How can I help :)",
|
297
|
+
from: {
|
298
|
+
type: "admin",
|
299
|
+
id: "1234"
|
305
300
|
},
|
306
|
-
:
|
307
|
-
:
|
308
|
-
:
|
301
|
+
to: {
|
302
|
+
type: "contact",
|
303
|
+
id: "536e5643as316c83104c400671"
|
309
304
|
}
|
310
305
|
})
|
311
306
|
|
312
307
|
# Message from a contact
|
313
308
|
intercom.messages.create({
|
314
|
-
:
|
315
|
-
:
|
316
|
-
:
|
309
|
+
from: {
|
310
|
+
type: "contact",
|
311
|
+
id: "536e5643as316c83104c400671"
|
317
312
|
},
|
318
|
-
:
|
313
|
+
body: "halp"
|
319
314
|
})
|
320
315
|
```
|
321
316
|
|
322
317
|
#### Events
|
323
318
|
```ruby
|
324
319
|
intercom.events.create(
|
325
|
-
:
|
326
|
-
:
|
327
|
-
:
|
320
|
+
event_name: "invited-friend",
|
321
|
+
created_at: Time.now.to_i,
|
322
|
+
email: user.email,
|
323
|
+
metadata: {
|
328
324
|
"invitee_email" => "pi@example.org",
|
329
|
-
:
|
325
|
+
invite_code: "ADDAFRIEND",
|
330
326
|
"found_date" => 12909364407
|
331
327
|
}
|
332
328
|
)
|
@@ -339,25 +335,27 @@ intercom.events.create(
|
|
339
335
|
Metadata Objects support a few simple types that Intercom can present on your behalf
|
340
336
|
|
341
337
|
```ruby
|
342
|
-
intercom.events.create(
|
343
|
-
:
|
344
|
-
:
|
345
|
-
|
346
|
-
|
347
|
-
:
|
348
|
-
|
349
|
-
|
338
|
+
intercom.events.create(
|
339
|
+
event_name: "placed-order",
|
340
|
+
email: current_user.email,
|
341
|
+
created_at: 1403001013,
|
342
|
+
metadata: {
|
343
|
+
order_date: Time.now.to_i,
|
344
|
+
stripe_invoice: 'inv_3434343434',
|
345
|
+
order_number: {
|
346
|
+
value: '3434-3434',
|
347
|
+
url: 'https://example.org/orders/3434-3434'
|
350
348
|
},
|
351
349
|
price: {
|
352
|
-
:
|
353
|
-
:
|
350
|
+
currency: 'usd',
|
351
|
+
amount: 2999
|
354
352
|
}
|
355
353
|
}
|
356
354
|
)
|
357
355
|
```
|
358
356
|
|
359
357
|
The metadata key values in the example are treated as follows-
|
360
|
-
- order_date: a Date (key ends with '_date')
|
358
|
+
- order_date: a Date (key ends with '_date')
|
361
359
|
- stripe_invoice: The identifier of the Stripe invoice (has a 'stripe_invoice' key)
|
362
360
|
- order_number: a Rich Link (value contains 'url' and 'value' keys)
|
363
361
|
- price: An Amount in US Dollars (value contains 'amount' and 'currency' keys)
|
@@ -450,10 +448,10 @@ Subscribe to events in Intercom to receive webhooks.
|
|
450
448
|
|
451
449
|
```ruby
|
452
450
|
# create a subscription
|
453
|
-
intercom.subscriptions.create(:
|
451
|
+
intercom.subscriptions.create(url: "http://example.com", topics: ["user.created"])
|
454
452
|
|
455
453
|
# fetch a subscription
|
456
|
-
intercom.subscriptions.find(:
|
454
|
+
intercom.subscriptions.find(id: "nsub_123456789")
|
457
455
|
|
458
456
|
# list subscriptions
|
459
457
|
intercom.subscriptions.all
|
data/intercom.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "fakeweb", ["~> 1.3"]
|
26
26
|
spec.add_development_dependency "pry"
|
27
27
|
|
28
|
-
spec.add_dependency 'json', '
|
28
|
+
spec.add_dependency 'json', '>= 1.8'
|
29
29
|
spec.required_ruby_version = '>= 2.1.0'
|
30
30
|
spec.add_development_dependency 'gem-release'
|
31
31
|
end
|
data/lib/intercom.rb
CHANGED
data/lib/intercom/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intercom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben McRedmond
|
@@ -15,7 +15,7 @@ authors:
|
|
15
15
|
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
|
-
date:
|
18
|
+
date: 2017-01-10 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: minitest
|
@@ -91,14 +91,14 @@ dependencies:
|
|
91
91
|
name: json
|
92
92
|
requirement: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.8'
|
97
97
|
type: :runtime
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '1.8'
|
104
104
|
- !ruby/object:Gem::Dependency
|
@@ -242,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
242
242
|
version: '0'
|
243
243
|
requirements: []
|
244
244
|
rubyforge_project: intercom
|
245
|
-
rubygems_version: 2.
|
245
|
+
rubygems_version: 2.4.8
|
246
246
|
signing_key:
|
247
247
|
specification_version: 4
|
248
248
|
summary: Ruby bindings for the Intercom API
|