intercom 4.0.0 → 4.0.1

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
- SHA1:
3
- metadata.gz: 5c53964236b264ffc6d830868e44ca4a49aa5e99
4
- data.tar.gz: b2780da686165e965b18a36e9ab3016e78283178
2
+ SHA256:
3
+ metadata.gz: c2825cafe4bba63c25a6a4c520d2eb001cd76442b6fcbcd6454eab4c6319dfd6
4
+ data.tar.gz: 912189efc621173579186ebc5aabecb8fb71e96306a722cd68a477d423c50f61
5
5
  SHA512:
6
- metadata.gz: '002628c67583066ae5994bfaf1a2ff90b8111f761ab031c13a573eeeab97456572bdc821bd64e67f20fba10548edf090b4bd39ec4d8b16b77f619f754c1c3118'
7
- data.tar.gz: e7d16ab3173ad4ebdfdd2f616179483b24d82f8182e250d251a9723d6ca81ce0fa117b04bc98d99eda45a07ec360e5f0daa6755f32ec76004bca8816a0f585fe
6
+ metadata.gz: 51c4b80bef30445a5cdee9cd6f3715e34857d1879295626cd475eb49881c19f1647a11caadaa3828e99d33009ce88b973839429b7ef54950d047ffb2eb4f1df5
7
+ data.tar.gz: 44529233028270a8da89edacf0f0d07cfe465faf4d04ea60559ab8a6e2cbbc71e3de2e4b273515da3449e50d9b7f098cfdc585a130fc4b5d6a70556b6ce781ef
data/README.md CHANGED
@@ -61,7 +61,7 @@ Resources this API supports:
61
61
  https://api.intercom.io/counts
62
62
  https://api.intercom.io/subscriptions
63
63
  https://api.intercom.io/jobs
64
-
64
+
65
65
 
66
66
  ### Examples
67
67
 
@@ -99,7 +99,7 @@ contacts = intercom.contacts.search(
99
99
  }
100
100
  )
101
101
  contacts.each {|c| p c.email}
102
- # For full detail on possible queries, please refer to the API documentation:
102
+ # For full detail on possible queries, please refer to the API documentation:
103
103
  # https://developers.intercom.com/intercom-api-reference/reference
104
104
 
105
105
  # Merge a lead into an existing user
@@ -191,7 +191,7 @@ intercom.data_attributes.save(attribute)
191
191
  attribute.archived = true
192
192
  intercom.data_attributes.save(attribute)
193
193
 
194
- # Find all customer attributes including archived
194
+ # Find all customer attributes including archived
195
195
  customer_attributes_incl_archived = intercom.data_attributes.find_all({"model": "contact", "include_archived": true})
196
196
  customer_attributes_incl_archived.each { |attr| p attribute.name }
197
197
  ```
@@ -321,7 +321,7 @@ conversation.statistics.time_to_admin_reply
321
321
  conversation.statistics.last_assignment_at
322
322
 
323
323
  # Get information on the sla applied to a conversation
324
- conversation.sla_applied.sla_name
324
+ conversation.sla_applied.sla_name
325
325
 
326
326
  # REPLYING TO CONVERSATIONS
327
327
  # User (identified by email) replies with a comment
@@ -370,9 +370,9 @@ intercom.conversations.mark_read(conversation.id)
370
370
  intercom.conversations.run_assignment_rules(conversation.id)
371
371
 
372
372
  # Search for conversations
373
- # For full detail on possible queries, please refer to the API documentation:
374
- # https://developers.intercom.com/intercom-api-reference/reference
375
-
373
+ # For full detail on possible queries, please refer to the API documentation:
374
+ # https://developers.intercom.com/intercom-api-reference/reference
375
+
376
376
  # Search for open conversations sorted by the created_at date
377
377
  conversations = intercom.conversations.search(
378
378
  query: {
@@ -386,18 +386,23 @@ conversations = intercom.conversations.search(
386
386
  conversations.each {|c| p c.id}
387
387
 
388
388
  # Tagging for conversations
389
- tag = intercom.tags.find(id: "2")
389
+ tag = intercom.tags.find(id: "2")
390
390
  conversation = intercom.conversations.find(id: "1")
391
391
 
392
392
  # An Admin ID is required to add or remove tag on a conversation
393
- admin = intercom.admins.find(id: "1")
393
+ admin = intercom.admins.find(id: "1")
394
394
 
395
395
  # Add a tag to a conversation
396
396
  conversation.add_tag(id: tag.id, admin_id: admin.id)
397
397
 
398
398
  # Remove a tag from a conversation
399
399
  conversation.remove_tag(id: tag.id, admin_id: admin.id)
400
-
400
+
401
+ # Add a contact to a conversation
402
+ conversation.add_contact(admin_id: admin.id, customer: { intercom_user_id: contact.id })
403
+
404
+ # Remove a contact from a conversation
405
+ conversation.remove_contact(id: contact.id, admin_id: admin.id)
401
406
  ```
402
407
 
403
408
  #### Full loading of an embedded entity
@@ -1,3 +1,11 @@
1
+ 4.0
2
+ New version to support API version 2.0.
3
+ - Added support for new Contacts API.
4
+ - Added support for Conversation Search and for Conversation model changes.
5
+ - New DataAttribute class to support the Data Attributes. See README for details on usage.
6
+ - New method to run assignment rules on a conversation: `intercom.conversations.run_assignment_rules(<convo_id>)`.
7
+ - See Migration guide for breaking changes: https://github.com/intercom/intercom-ruby/wiki/Migration-guide-for-v4
8
+
1
9
  3.9.5
2
10
  Add Unstable version support
3
11
 
@@ -27,6 +27,7 @@ module Intercom
27
27
  else
28
28
  response = @client.post("/#{collection_name}", object.to_submittable_hash.merge(identity_hash(object)))
29
29
  end
30
+ object.client = @client
30
31
  object.from_response(response) if response # may be nil we received back a 202
31
32
  end
32
33
 
@@ -7,5 +7,6 @@ module Intercom
7
7
  include ApiOperations::NestedResource
8
8
 
9
9
  nested_resource_methods :tag, operations: %i[add delete]
10
+ nested_resource_methods :contact, operations: %i[add delete], path: :customers
10
11
  end
11
12
  end
@@ -1,3 +1,3 @@
1
1
  module Intercom #:nodoc:
2
- VERSION = "4.0.0"
2
+ VERSION = "4.0.1"
3
3
  end
@@ -311,5 +311,60 @@ describe Intercom::Contact do
311
311
  client.expects(:delete).with("/contacts/1/companies/#{company.id}", "id": tag.id ).returns(test_company)
312
312
  contact.remove_company({ "id": tag.id })
313
313
  end
314
+
315
+ describe 'just after creating the contact' do
316
+ let(:contact) do
317
+ contact = Intercom::Contact.new('email' => 'jo@example.com', :external_id => 'i-1224242')
318
+ client.expects(:post).with('/contacts', 'email' => 'jo@example.com', 'external_id' => 'i-1224242', 'custom_attributes' => {})
319
+ .returns('id' => 1, 'email' => 'jo@example.com', 'external_id' => 'i-1224242')
320
+ client.contacts.save(contact)
321
+ end
322
+
323
+ it 'returns a collection proxy for listing notes' do
324
+ proxy = contact.notes
325
+ _(proxy.resource_name).must_equal 'notes'
326
+ _(proxy.url).must_equal '/contacts/1/notes'
327
+ _(proxy.resource_class).must_equal Intercom::Note
328
+ end
329
+
330
+ it 'returns a collection proxy for listing tags' do
331
+ proxy = contact.tags
332
+ _(proxy.resource_name).must_equal 'tags'
333
+ _(proxy.url).must_equal '/contacts/1/tags'
334
+ _(proxy.resource_class).must_equal Intercom::Tag
335
+ end
336
+
337
+ it 'returns a collection proxy for listing companies' do
338
+ proxy = contact.companies
339
+ _(proxy.resource_name).must_equal 'companies'
340
+ _(proxy.url).must_equal '/contacts/1/companies'
341
+ _(proxy.resource_class).must_equal Intercom::Company
342
+ end
343
+
344
+ it 'adds a note to a contact' do
345
+ client.expects(:post).with('/contacts/1/notes', {body: note.body}).returns(note.to_hash)
346
+ contact.create_note({body: note.body})
347
+ end
348
+
349
+ it 'adds a tag to a contact' do
350
+ client.expects(:post).with('/contacts/1/tags', "id": tag.id).returns(tag.to_hash)
351
+ contact.add_tag({ "id": tag.id })
352
+ end
353
+
354
+ it 'removes a tag from a contact' do
355
+ client.expects(:delete).with("/contacts/1/tags/#{tag.id}", "id": tag.id ).returns(tag.to_hash)
356
+ contact.remove_tag({ "id": tag.id })
357
+ end
358
+
359
+ it 'adds a contact to a company' do
360
+ client.expects(:post).with('/contacts/1/companies', "id": company.id).returns(test_company)
361
+ contact.add_company({ "id": tag.id })
362
+ end
363
+
364
+ it 'removes a contact from a company' do
365
+ client.expects(:delete).with("/contacts/1/companies/#{company.id}", "id": tag.id ).returns(test_company)
366
+ contact.remove_company({ "id": tag.id })
367
+ end
368
+ end
314
369
  end
315
370
  end
@@ -81,5 +81,31 @@ describe "Intercom::Conversation" do
81
81
  client.expects(:delete).with("/conversations/1/tags/1", { "id": tag.id }).returns(nil)
82
82
  _(proc { conversation.remove_tag({ "id": tag.id }) }).must_raise Intercom::HttpError
83
83
  end
84
+
85
+ describe 'contacts' do
86
+ let(:response) do
87
+ {
88
+ customers: [
89
+ { type: test_contact['type'], id: test_contact['id'] }
90
+ ]
91
+ }
92
+ end
93
+
94
+ it 'adds a contact to a conversation' do
95
+ client.expects(:post)
96
+ .with("/conversations/1/customers",
97
+ { admin_id: test_admin['id'], customer: { intercom_user_id: test_contact['id'] } })
98
+ .returns(response.to_hash)
99
+ conversation.add_contact(admin_id: test_admin['id'], customer: { intercom_user_id: test_contact['id'] })
100
+ end
101
+
102
+ it 'removes a contact from a conversation' do
103
+ client.expects(:delete)
104
+ .with("/conversations/1/customers/aaaaaaaaaaaaaaaaaaaaaaaa",
105
+ { id: 'aaaaaaaaaaaaaaaaaaaaaaaa', admin_id: '1234' })
106
+ .returns(response.to_hash)
107
+ conversation.remove_contact(id: test_contact['id'], admin_id: test_admin['id'])
108
+ end
109
+ end
84
110
  end
85
111
  end
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: 4.0.0
4
+ version: 4.0.1
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: 2020-01-30 00:00:00.000000000 Z
18
+ date: 2020-03-10 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: minitest
@@ -262,8 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
262
262
  - !ruby/object:Gem::Version
263
263
  version: '0'
264
264
  requirements: []
265
- rubyforge_project:
266
- rubygems_version: 2.5.2.3
265
+ rubygems_version: 3.0.3
267
266
  signing_key:
268
267
  specification_version: 4
269
268
  summary: Ruby bindings for the Intercom API