intercom 3.5.12 → 3.5.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84719dadeaf7d2aeff38ba123e258b8d13dda3ca
4
- data.tar.gz: 6f5b639d8f587bd42a62c7807437ff70e2643a4e
3
+ metadata.gz: 8cf1ca0778bd7e64ae81296aa6dadb5414c80aea
4
+ data.tar.gz: 698516d5a4b3e43e7b44325a03cc20f7675b6849
5
5
  SHA512:
6
- metadata.gz: 8af7c5cc8fb66238a15c2fc20888ffd6f9914c800b0983bc281c737270899cbc9652d709fa82ad84b32ae94d5a84a0983badac8ecf8b6e58890c800ffcf5e0de
7
- data.tar.gz: 373c03846b1fd01ae42ad8214b65bcf2abe00ea31351214410476dff921501862e463a2f2a2a89674ccbbe424110831a0cd05cd6170017ec2a65da1b75bb255a
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 for assigned an admin, before a certain moment in time
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
 
@@ -1,3 +1,9 @@
1
+ 3.5.12
2
+ - Use base_url in initialize parameter
3
+
4
+ 3.5.11
5
+ - Add scroll api for companies
6
+
1
7
  3.5.10
2
8
  - Add Support for find_all events pagination (@jkeyes)
3
9
 
@@ -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 = 'https://api.intercom.io'
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
- result = request.execute(@base_url, username: @username_part, secret: @password_part)
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)
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Intercom #:nodoc:
2
- VERSION = "3.5.12"
2
+ VERSION = "3.5.14"
3
3
  end
@@ -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.12
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-02-16 00:00:00.000000000 Z
18
+ date: 2017-05-19 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: minitest