intercom 4.1.1 → 4.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/changes.txt +3 -0
- data/lib/intercom/contact.rb +1 -0
- data/lib/intercom/scroll_collection_proxy.rb +6 -5
- data/lib/intercom/segment.rb +4 -0
- data/lib/intercom/service/company.rb +2 -0
- data/lib/intercom/service/contact.rb +10 -0
- data/lib/intercom/service/conversation.rb +1 -1
- data/lib/intercom/version.rb +1 -1
- data/spec/unit/intercom/company_spec.rb +6 -0
- data/spec/unit/intercom/contact_spec.rb +19 -0
- data/spec/unit/intercom/conversation_spec.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebb883bd25fc8d132306baac3a22c43650701dbe42d42b95ada3819bc52cc2d6
|
4
|
+
data.tar.gz: 8d1158c4d79cf19916c6cc1d413c329588d1ff36b5741517e029415e0f992360
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/changes.txt
CHANGED
data/lib/intercom/contact.rb
CHANGED
@@ -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 =
|
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
|
-
|
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
|
59
|
-
top_level_type = response_hash
|
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[
|
69
|
+
!response_hash[entity_key_from_response(response_hash)].empty?
|
69
70
|
end
|
70
71
|
|
71
72
|
def extract_scroll_param(response_hash)
|
data/lib/intercom/segment.rb
CHANGED
@@ -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
|
data/lib/intercom/version.rb
CHANGED
@@ -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.
|
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-
|
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:
|