intercom 3.5.12 → 3.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -69
- data/changes.txt +6 -0
- data/lib/intercom/client.rb +4 -4
- data/lib/intercom/request.rb +2 -0
- data/lib/intercom/version.rb +1 -1
- data/spec/unit/intercom/request_spec.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cf1ca0778bd7e64ae81296aa6dadb5414c80aea
|
4
|
+
data.tar.gz: 698516d5a4b3e43e7b44325a03cc20f7675b6849
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06bd3d79d91911456744b179287d78f6b752b063d4e4a02a8cb8205ba9b4ee72d1ef97d6cd50cc09e62bcba302ffe0cc97676a249f418a596d8d506497a12024
|
7
|
+
data.tar.gz: 35863aff023fc454d73bdd4bcfde829158682ff5685e0ae2445661dadbd6504bf47314b5963f67d7c92feeb0174f164df83dacdb53dfcc398c0213ea721415ed
|
data/README.md
CHANGED
@@ -54,7 +54,6 @@ Resources this API supports:
|
|
54
54
|
https://api.intercom.io/messages
|
55
55
|
https://api.intercom.io/subscriptions
|
56
56
|
https://api.intercom.io/jobs
|
57
|
-
https://api.intercom.io/bulk
|
58
57
|
|
59
58
|
### Examples
|
60
59
|
|
@@ -100,16 +99,6 @@ result = intercom.users.scroll.next
|
|
100
99
|
result.scroll_param
|
101
100
|
=> "0730e341-63ef-44da-ab9c-9113f886326d"
|
102
101
|
result = intercom.users.scroll.next("0730e341-63ef-44da-ab9c-9113f886326d");
|
103
|
-
|
104
|
-
#Bulk operations.
|
105
|
-
# Submit bulk job to create users. If any of the items in create_items match an existing user that user will be updated
|
106
|
-
intercom.users.submit_bulk_job(create_items: [{user_id: "25", email: "alice@example.com"}, {user_id: "25", email: "bob@example.com"}])
|
107
|
-
# Submit bulk job to create users with companies. Companies must be sent as an array of objects nested within each applicable user object
|
108
|
-
intercom.users.submit_bulk_job(create_items: [{user_id: "25", email: "alice@example.com", companies: [{company_id: 9, name: "Test Company"}]}])
|
109
|
-
# Submit bulk job, to delete users
|
110
|
-
intercom.users.submit_bulk_job(delete_items: [{user_id: "25", email: "alice@example.com"}, {user_id: "25", email: "bob@example.com"}])
|
111
|
-
# Submit bulk job, to add items to existing job
|
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')
|
113
102
|
```
|
114
103
|
|
115
104
|
#### Admins
|
@@ -189,7 +178,7 @@ intercom.conversations.find_all(type: 'admin', id: '7').each {|convo| ... }
|
|
189
178
|
intercom.conversations.find_all(type: 'admin', id: 7, open: true).each {|convo| ... }
|
190
179
|
# Iterate over closed conversations assigned to an admin
|
191
180
|
intercom.conversations.find_all(type: 'admin', id: 7, open: false).each {|convo| ... }
|
192
|
-
# Iterate over closed conversations
|
181
|
+
# Iterate over closed conversations which are assigned to an admin, and where updated_at is before a certain moment in time
|
193
182
|
intercom.conversations.find_all(type: 'admin', id: 7, open: false, before: 1374844930).each {|convo| ... }
|
194
183
|
|
195
184
|
# FINDING CONVERSATIONS FOR A USER
|
@@ -362,54 +351,6 @@ The metadata key values in the example are treated as follows-
|
|
362
351
|
|
363
352
|
*NB:* This version of the gem reserves the field name `type` in Event data.
|
364
353
|
|
365
|
-
Bulk operations.
|
366
|
-
```ruby
|
367
|
-
# Submit bulk job, to create events
|
368
|
-
intercom.events.submit_bulk_job(create_items: [
|
369
|
-
{
|
370
|
-
event_name: "ordered-item",
|
371
|
-
created_at: 1438944980,
|
372
|
-
user_id: "314159",
|
373
|
-
metadata: {
|
374
|
-
order_date: 1438944980,
|
375
|
-
stripe_invoice: "inv_3434343434"
|
376
|
-
}
|
377
|
-
},
|
378
|
-
{
|
379
|
-
event_name: "invited-friend",
|
380
|
-
created_at: 1438944979,
|
381
|
-
user_id: "314159",
|
382
|
-
metadata: {
|
383
|
-
invitee_email: "pi@example.org",
|
384
|
-
invite_code: "ADDAFRIEND"
|
385
|
-
}
|
386
|
-
}
|
387
|
-
])
|
388
|
-
|
389
|
-
|
390
|
-
# Submit bulk job, to add items to existing job
|
391
|
-
intercom.events.submit_bulk_job(create_items: [
|
392
|
-
{
|
393
|
-
event_name: "ordered-item",
|
394
|
-
created_at: 1438944980,
|
395
|
-
user_id: "314159",
|
396
|
-
metadata: {
|
397
|
-
order_date: 1438944980,
|
398
|
-
stripe_invoice: "inv_3434343434"
|
399
|
-
}
|
400
|
-
},
|
401
|
-
{
|
402
|
-
event_name: "invited-friend",
|
403
|
-
created_at: 1438944979,
|
404
|
-
user_id: "314159",
|
405
|
-
metadata: {
|
406
|
-
invitee_email: "pi@example.org",
|
407
|
-
invite_code: "ADDAFRIEND"
|
408
|
-
}
|
409
|
-
}
|
410
|
-
], job_id:'job_abcd1234')
|
411
|
-
```
|
412
|
-
|
413
354
|
### Contacts
|
414
355
|
|
415
356
|
`Contacts` represent logged out users of your application.
|
@@ -453,18 +394,13 @@ intercom.subscriptions.create(url: "http://example.com", topics: ["user.created"
|
|
453
394
|
# fetch a subscription
|
454
395
|
intercom.subscriptions.find(id: "nsub_123456789")
|
455
396
|
|
397
|
+
# delete a subscription
|
398
|
+
subscription = intercom.subscriptions.find(id: "nsub_123456789")
|
399
|
+
intercom.subscriptions.delete(subscription)
|
400
|
+
|
456
401
|
# list subscriptions
|
457
402
|
intercom.subscriptions.all
|
458
403
|
```
|
459
|
-
### Bulk jobs
|
460
|
-
|
461
|
-
```ruby
|
462
|
-
# fetch a job
|
463
|
-
intercom.jobs.find(id: 'job_abcd1234')
|
464
|
-
|
465
|
-
# fetch a job's error feed
|
466
|
-
intercom.jobs.errors(id: 'job_abcd1234')
|
467
|
-
```
|
468
404
|
|
469
405
|
### Errors
|
470
406
|
|
data/changes.txt
CHANGED
data/lib/intercom/client.rb
CHANGED
@@ -14,7 +14,7 @@ module Intercom
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def initialize(app_id: 'my_app_id', api_key: 'my_api_key', token: nil)
|
17
|
+
def initialize(app_id: 'my_app_id', api_key: 'my_api_key', token: nil, base_url:'https://api.intercom.io')
|
18
18
|
if token
|
19
19
|
@username_part = token
|
20
20
|
@password_part = ""
|
@@ -24,7 +24,7 @@ module Intercom
|
|
24
24
|
end
|
25
25
|
validate_credentials!
|
26
26
|
|
27
|
-
@base_url =
|
27
|
+
@base_url = base_url
|
28
28
|
@rate_limit_details = {}
|
29
29
|
end
|
30
30
|
|
@@ -108,9 +108,9 @@ module Intercom
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def execute_request(request)
|
111
|
-
|
111
|
+
request.execute(@base_url, username: @username_part, secret: @password_part)
|
112
|
+
ensure
|
112
113
|
@rate_limit_details = request.rate_limit_details
|
113
|
-
result
|
114
114
|
end
|
115
115
|
|
116
116
|
def base_url=(new_url)
|
data/lib/intercom/request.rb
CHANGED
@@ -115,6 +115,8 @@ module Intercom
|
|
115
115
|
raise Intercom::AuthenticationError.new('Unauthorized')
|
116
116
|
elsif res.code.to_i.eql?(403)
|
117
117
|
raise Intercom::AuthenticationError.new('Forbidden')
|
118
|
+
elsif res.code.to_i.eql?(429)
|
119
|
+
raise Intercom::RateLimitExceeded.new('Rate Limit Exceeded')
|
118
120
|
elsif res.code.to_i.eql?(500)
|
119
121
|
raise Intercom::ServerError.new('Server Error')
|
120
122
|
elsif res.code.to_i.eql?(502)
|
data/lib/intercom/version.rb
CHANGED
@@ -8,6 +8,12 @@ describe 'Intercom::Request' do
|
|
8
8
|
proc {req.parse_body('<html>somethjing</html>', response)}.must_raise(Intercom::ServerError)
|
9
9
|
end
|
10
10
|
|
11
|
+
it 'raises a RateLimitExceeded error when the response code is 429' do
|
12
|
+
response = OpenStruct.new(:code => 429)
|
13
|
+
req = Intercom::Request.new('path/', 'GET')
|
14
|
+
proc {req.parse_body('<html>somethjing</html>', response)}.must_raise(Intercom::RateLimitExceeded)
|
15
|
+
end
|
16
|
+
|
11
17
|
it 'parse_body returns nil if decoded_body is nil' do
|
12
18
|
response = OpenStruct.new(:code => 500)
|
13
19
|
req = Intercom::Request.new('path/', 'GET')
|
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.14
|
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: 2017-
|
18
|
+
date: 2017-05-19 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: minitest
|