intercom 4.1.1 → 4.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fa157332954bf84fd08a22313a71f4435b78336674c268829a64e1c14995dc3
4
- data.tar.gz: e5773633f34167729c300fe0906c2cb2550f8e90f69aaf43a8142e08386b455f
3
+ metadata.gz: ebb883bd25fc8d132306baac3a22c43650701dbe42d42b95ada3819bc52cc2d6
4
+ data.tar.gz: 8d1158c4d79cf19916c6cc1d413c329588d1ff36b5741517e029415e0f992360
5
5
  SHA512:
6
- metadata.gz: d1b492cab3734c3b2a2f861cf481e64f86b7f7179c80f82f5c4f187fcf6579eba2f2bfa1a948160bdac8142262e491942c036b894e400f7833310a119677936c
7
- data.tar.gz: e6d5b2f5dc751ed7f8b12e4ade49164d3d28831cb8f2ec4d30d15780c2c74b5bc5a4a48680a14136e1505a8a1f773649ea8df65f7703eb0fb7ce6c0d74050ade
6
+ metadata.gz: 0a0ea848ac117043da9707f2f9689504abda06f34e218a077c0591216aa654c3e9ca73f9874f2255e7300cd3329c95ba6440232c30d58364877e7d358bf950d0
7
+ data.tar.gz: 95b5ffdd05e7332fcbd53061c08c380d8632bd9f11d09e3673da65ca25b4624377b409116292b41f626a0fc6b4ad3d1c5183e5315533d3b4f94fe285c74041a6
data/README.md CHANGED
@@ -86,6 +86,12 @@ intercom.contacts.save(contact)
86
86
  contact.role = "user"
87
87
  intercom.contacts.save(contact)
88
88
 
89
+ # Archive a contact
90
+ intercom.contacts.archive(contact)
91
+
92
+ # Unarchive a contact
93
+ intercom.contacts.unarchive(contact)
94
+
89
95
  # Delete a contact permanently
90
96
  intercom.contacts.delete(contact)
91
97
 
@@ -125,6 +131,9 @@ contact.create_note(body: "<p>Text for the note</p>")
125
131
  # List notes for a contact
126
132
  contact.notes.each {|n| p n.body}
127
133
 
134
+ # List segments for a contact
135
+ contact.segments.each {|segment| p segment.name}
136
+
128
137
  # Add a contact to a company
129
138
  company = intercom.companies.find(id: "123")
130
139
  contact.add_company(id: company.id)
@@ -166,6 +175,9 @@ company = intercom.companies.find(id: "41e66f0313708347cb0000d0")
166
175
  company.name = 'Updated company name'
167
176
  intercom.companies.save(company)
168
177
 
178
+ # Delete a company
179
+ intercom.companies.delete(company)
180
+
169
181
  # Iterate over all companies
170
182
  intercom.companies.all.each {|company| puts %Q(#{company.name} - #{company.custom_attributes["referral_source"]}) }
171
183
  intercom.companies.all.map {|company| company.name }
@@ -261,6 +273,9 @@ intercom.tags.all.map {|tag| tag.name }
261
273
 
262
274
  # Tag companies
263
275
  tag = intercom.tags.tag(name: 'blue', companies: [{company_id: "42ea2f1b93891f6a99000427"}])
276
+
277
+ # Untag Companies
278
+ tag = intercom.tags.untag(name: 'blue', companies: [{ company_id: "42ea2f1b93891f6a99000427" }])
264
279
  ```
265
280
 
266
281
  #### Notes
@@ -1,3 +1,6 @@
1
+ 4.1.1
2
+ - Fixed bug with deprecated lead resource.
3
+
1
4
  4.1.0
2
5
  - Added support for new Articles API.
3
6
  - Added support for new Collections API.
@@ -13,6 +13,7 @@ module Intercom
13
13
  nested_resource_methods :tag, operations: %i[add delete list]
14
14
  nested_resource_methods :note, operations: %i[create list]
15
15
  nested_resource_methods :company, operations: %i[add delete list]
16
+ nested_resource_methods :segment, operations: %i[list]
16
17
 
17
18
  def self.collection_proxy_class
18
19
  Intercom::BaseCollectionProxy
@@ -26,7 +26,7 @@ module Intercom
26
26
  raise Intercom::HttpError, 'Http Error - No response entity returned' unless response_hash
27
27
 
28
28
  @scroll_param = extract_scroll_param(response_hash)
29
- top_level_entity_key = deserialize_response_hash(response_hash)
29
+ top_level_entity_key = entity_key_from_response(response_hash)
30
30
  response_hash[top_level_entity_key] = response_hash[top_level_entity_key].map do |object_json|
31
31
  Lib::TypedJsonDeserializer.new(object_json, @client).deserialize
32
32
  end
@@ -44,7 +44,8 @@ module Intercom
44
44
  end
45
45
  raise Intercom::HttpError, 'Http Error - No response entity returned' unless response_hash
46
46
 
47
- response_hash[deserialize_response_hash(response_hash)].each do |object_json|
47
+ top_level_entity_key = entity_key_from_response(response_hash)
48
+ response_hash[top_level_entity_key].each do |object_json|
48
49
  block.call Lib::TypedJsonDeserializer.new(object_json, @client).deserialize
49
50
  end
50
51
  scroll_param = extract_scroll_param(response_hash)
@@ -55,8 +56,8 @@ module Intercom
55
56
 
56
57
  private
57
58
 
58
- def deserialize_response_hash(response_hash)
59
- top_level_type = response_hash.delete('type')
59
+ def entity_key_from_response(response_hash)
60
+ top_level_type = response_hash['type']
60
61
  if resource_name == 'subscriptions'
61
62
  'items'
62
63
  else
@@ -65,7 +66,7 @@ module Intercom
65
66
  end
66
67
 
67
68
  def records_present?(response_hash)
68
- !response_hash[@resource_name].empty?
69
+ !response_hash[entity_key_from_response(response_hash)].empty?
69
70
  end
70
71
 
71
72
  def extract_scroll_param(response_hash)
@@ -3,5 +3,9 @@ require 'intercom/traits/api_resource'
3
3
  module Intercom
4
4
  class Segment
5
5
  include Traits::ApiResource
6
+
7
+ def self.collection_proxy_class
8
+ Intercom::BaseCollectionProxy
9
+ end
6
10
  end
7
11
  end
@@ -1,4 +1,5 @@
1
1
  require 'intercom/service/base_service'
2
+ require 'intercom/api_operations/delete'
2
3
  require 'intercom/api_operations/list'
3
4
  require 'intercom/api_operations/scroll'
4
5
  require 'intercom/api_operations/find'
@@ -11,6 +12,7 @@ require 'intercom/extended_api_operations/segments'
11
12
  module Intercom
12
13
  module Service
13
14
  class Company < BaseService
15
+ include ApiOperations::Delete
14
16
  include ApiOperations::Find
15
17
  include ApiOperations::FindAll
16
18
  include ApiOperations::Load
@@ -33,6 +33,16 @@ module Intercom
33
33
  user.from_response(response)
34
34
  end
35
35
 
36
+ def archive(contact)
37
+ @client.post("/#{collection_name}/#{contact.id}/archive", {})
38
+ contact
39
+ end
40
+
41
+ def unarchive(contact)
42
+ @client.post("/#{collection_name}/#{contact.id}/unarchive", {})
43
+ contact
44
+ end
45
+
36
46
  private def raise_invalid_merge_error
37
47
  raise Intercom::InvalidMergeError, 'Merging can only be performed on a lead into a user'
38
48
  end
@@ -58,7 +58,7 @@ module Intercom
58
58
 
59
59
  def run_assignment_rules(id)
60
60
  collection_name = Utils.resource_class_to_collection_name(collection_class)
61
- response = @client.post("/#{collection_name}/#{id}/run_assignment_rules")
61
+ response = @client.post("/#{collection_name}/#{id}/run_assignment_rules", {})
62
62
  collection_class.new.from_response(response)
63
63
  end
64
64
  end
@@ -1,3 +1,3 @@
1
1
  module Intercom #:nodoc:
2
- VERSION = "4.1.1"
2
+ VERSION = "4.1.2"
3
3
  end
@@ -35,4 +35,10 @@ describe Intercom::Company do
35
35
  _(proxy.url).must_equal '/companies/1/contacts'
36
36
  _(proxy.resource_class).must_equal Intercom::Contact
37
37
  end
38
+
39
+ it "deletes a company" do
40
+ company = Intercom::Company.new("id" => "1")
41
+ client.expects(:delete).with("/companies/1", {})
42
+ client.companies.delete(company)
43
+ end
38
44
  end
@@ -248,6 +248,18 @@ describe Intercom::Contact do
248
248
  client.contacts.delete(contact)
249
249
  end
250
250
 
251
+ it 'archives a contact' do
252
+ contact = Intercom::Contact.new('id' => '1')
253
+ client.expects(:post).with('/contacts/1/archive', {})
254
+ client.contacts.archive(contact)
255
+ end
256
+
257
+ it 'unarchives a contact' do
258
+ contact = Intercom::Contact.new('id' => '1')
259
+ client.expects(:post).with('/contacts/1/unarchive', {})
260
+ client.contacts.unarchive(contact)
261
+ end
262
+
251
263
  describe 'merging' do
252
264
  let(:lead) { Intercom::Contact.from_api(external_id: 'contact_id', role: 'lead') }
253
265
  let(:user) { Intercom::Contact.from_api(id: 'external_id', role: 'user') }
@@ -273,6 +285,13 @@ describe Intercom::Contact do
273
285
  _(proxy.resource_class).must_equal Intercom::Note
274
286
  end
275
287
 
288
+ it 'returns a collection proxy for listing segments' do
289
+ proxy = contact.segments
290
+ _(proxy.resource_name).must_equal 'segments'
291
+ _(proxy.url).must_equal '/contacts/1/segments'
292
+ _(proxy.resource_class).must_equal Intercom::Segment
293
+ end
294
+
276
295
  it 'returns a collection proxy for listing tags' do
277
296
  proxy = contact.tags
278
297
  _(proxy.resource_name).must_equal 'tags'
@@ -54,7 +54,7 @@ describe "Intercom::Conversation" do
54
54
  end
55
55
 
56
56
  it 'runs assignment rules on a conversation' do
57
- client.expects(:post).with('/conversations/147/run_assignment_rules').returns(test_conversation)
57
+ client.expects(:post).with('/conversations/147/run_assignment_rules', {}).returns(test_conversation)
58
58
  client.conversations.run_assignment_rules('147')
59
59
  end
60
60
 
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.1.1
4
+ version: 4.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben McRedmond
@@ -12,10 +12,10 @@ authors:
12
12
  - Declan McGrath
13
13
  - Jamie Osler
14
14
  - Bob Long
15
- autorequire:
15
+ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2020-08-11 00:00:00.000000000 Z
18
+ date: 2020-10-30 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: minitest
@@ -256,7 +256,7 @@ homepage: https://www.intercom.io
256
256
  licenses:
257
257
  - MIT
258
258
  metadata: {}
259
- post_install_message:
259
+ post_install_message:
260
260
  rdoc_options: []
261
261
  require_paths:
262
262
  - lib
@@ -272,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
272
  version: '0'
273
273
  requirements: []
274
274
  rubygems_version: 3.0.3
275
- signing_key:
275
+ signing_key:
276
276
  specification_version: 4
277
277
  summary: Ruby bindings for the Intercom API
278
278
  test_files: