intercom 4.2.1 → 4.2.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 +4 -4
- data/README.md +1 -1
- data/changes.txt +4 -0
- data/intercom.gemspec +1 -1
- data/lib/intercom/lib/flat_store.rb +9 -2
- data/lib/intercom/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/intercom/contact_spec.rb +1 -3
- data/spec/unit/intercom/lib/flat_store_spec.rb +33 -3
- data/spec/unit/intercom/user_spec.rb +1 -3
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea6de8ff389a01f714c1a0f5f42ffadf46b22f3636743fd58f76a9ad5c1ec458
|
4
|
+
data.tar.gz: 7e5da0a304fe4b90614fda3944d0f40089ab61db0e5aac0444235fde34186e49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1ab02970d6363d0b07424a2d9a09019ae69a29770d671045fb677332f4ce1621ee907d2e2ec0c6d29398374bc826c0ed197e6ff857813371f4d77d1c4b8692f
|
7
|
+
data.tar.gz: e821557df3b3eda19a519d0d51523b77434724a433e2e7ec651ebdb979b0e0847cab0576da9055e6e696b13987c3a66470edb21d4fca91d275b92b6ba0ac6337
|
data/README.md
CHANGED
@@ -170,7 +170,7 @@ contact.remove_company(id: company.id)
|
|
170
170
|
contact.companies.each {|c| p c.name}
|
171
171
|
|
172
172
|
# attach a subscription_types on a contact
|
173
|
-
contact.
|
173
|
+
contact.create_subscription_type(id: subscription_type.id)
|
174
174
|
|
175
175
|
# List subscription_types for a contact
|
176
176
|
contact.subscription_types.each {|n| p n.id}
|
data/changes.txt
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
4.2.2
|
2
|
+
- Fixed FlatStore to skip hash values when building API request payloads
|
3
|
+
- Removed hash validation on FlatStore reads to allow for custom objects
|
4
|
+
|
1
5
|
4.1.3
|
2
6
|
- Updated ReadMe with more errors.
|
3
7
|
- Fixed issue where paginated requests could only be iterated through once.
|
data/intercom.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency 'minitest', '~> 5.4'
|
22
22
|
spec.add_development_dependency "m", "~> 1.5.0"
|
23
23
|
spec.add_development_dependency 'rake', '~> 10.3'
|
24
|
-
spec.add_development_dependency 'mocha', '~>
|
24
|
+
spec.add_development_dependency 'mocha', '~> 2.0'
|
25
25
|
spec.add_development_dependency "fakeweb", ["~> 1.3"]
|
26
26
|
spec.add_development_dependency "pry"
|
27
27
|
|
@@ -2,7 +2,7 @@ module Intercom
|
|
2
2
|
module Lib
|
3
3
|
|
4
4
|
# Sub-class of {Hash} for storing custom data attributes.
|
5
|
-
# Doesn't allow
|
5
|
+
# Doesn't allow Arrays. And requires {String} or {Symbol} keys.
|
6
6
|
class FlatStore < Hash
|
7
7
|
|
8
8
|
def initialize(attributes={})
|
@@ -21,9 +21,16 @@ module Intercom
|
|
21
21
|
super(key.to_s)
|
22
22
|
end
|
23
23
|
|
24
|
+
def to_submittable_hash
|
25
|
+
# Filter out Custom Object references when submitting to API
|
26
|
+
self.reject do |key, value|
|
27
|
+
value.is_a?(Hash)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
24
31
|
private
|
25
32
|
def validate_key_and_value(key, value)
|
26
|
-
raise ArgumentError.new("This does not support nested data structures (key: #{key}, value: #{value}") if value.is_a?(Array)
|
33
|
+
raise ArgumentError.new("This does not support nested data structures (key: #{key}, value: #{value}") if value.is_a?(Array)
|
27
34
|
raise ArgumentError.new("Key must be String or Symbol: #{key}") unless key.is_a?(String) || key.is_a?(Symbol)
|
28
35
|
end
|
29
36
|
end
|
data/lib/intercom/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -90,12 +90,10 @@ describe Intercom::Contact do
|
|
90
90
|
_(contact.to_hash['custom_attributes']).must_equal 'mad' => 123, 'other' => now.to_i, 'thing' => 'yay'
|
91
91
|
end
|
92
92
|
|
93
|
-
it 'rejects
|
93
|
+
it 'rejects lists in custom_attributes' do
|
94
94
|
contact = Intercom::Contact.new
|
95
95
|
|
96
96
|
_(proc { contact.custom_attributes['thing'] = [1] }).must_raise(ArgumentError)
|
97
|
-
_(proc { contact.custom_attributes['thing'] = { 1 => 2 } }).must_raise(ArgumentError)
|
98
|
-
_(proc { contact.custom_attributes['thing'] = { 1 => { 2 => 3 } } }).must_raise(ArgumentError)
|
99
97
|
|
100
98
|
contact = Intercom::Contact.new(test_contact)
|
101
99
|
_(proc { contact.custom_attributes['thing'] = [1] }).must_raise(ArgumentError)
|
@@ -3,11 +3,15 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Intercom::Lib::FlatStore do
|
6
|
-
it 'raises if you try to set
|
6
|
+
it 'raises if you try to set arrays but allows hashes' do
|
7
7
|
data = Intercom::Lib::FlatStore.new
|
8
8
|
_(proc { data['thing'] = [1] }).must_raise ArgumentError
|
9
|
-
|
10
|
-
|
9
|
+
|
10
|
+
data['thing'] = { 'key' => 'value' }
|
11
|
+
_(data['thing']).must_equal({ 'key' => 'value' })
|
12
|
+
|
13
|
+
flat_store = Intercom::Lib::FlatStore.new('custom_object' => { 'type' => 'Order.list', 'instances' => [{'id' => '123'}] })
|
14
|
+
_(flat_store['custom_object']).must_equal({ 'type' => 'Order.list', 'instances' => [{'id' => '123'}] })
|
11
15
|
end
|
12
16
|
|
13
17
|
it 'raises if you try to use a non string key' do
|
@@ -28,4 +32,30 @@ describe Intercom::Lib::FlatStore do
|
|
28
32
|
_(data['b']).must_equal 2
|
29
33
|
_(data[:b]).must_equal 2
|
30
34
|
end
|
35
|
+
|
36
|
+
describe '#to_submittable_hash' do
|
37
|
+
it 'filters out all hash values' do
|
38
|
+
data = Intercom::Lib::FlatStore.new(
|
39
|
+
'regular_attr' => 'value',
|
40
|
+
'number_attr' => 42,
|
41
|
+
'custom_object' => {
|
42
|
+
'type' => 'Order.list',
|
43
|
+
'instances' => [
|
44
|
+
{ 'id' => '31', 'external_id' => 'ext_123' }
|
45
|
+
]
|
46
|
+
},
|
47
|
+
'regular_hash' => { 'key' => 'value' },
|
48
|
+
'metadata' => { 'source' => 'api', 'version' => 2 }
|
49
|
+
)
|
50
|
+
|
51
|
+
submittable = data.to_submittable_hash
|
52
|
+
|
53
|
+
_(submittable['regular_attr']).must_equal 'value'
|
54
|
+
_(submittable['number_attr']).must_equal 42
|
55
|
+
|
56
|
+
_(submittable.key?('custom_object')).must_equal false
|
57
|
+
_(submittable.key?('regular_hash')).must_equal false
|
58
|
+
_(submittable.key?('metadata')).must_equal false
|
59
|
+
end
|
60
|
+
end
|
31
61
|
end
|
@@ -106,12 +106,10 @@ describe 'Intercom::User' do
|
|
106
106
|
_(user.to_hash['companies']).must_equal companies
|
107
107
|
end
|
108
108
|
|
109
|
-
it 'rejects
|
109
|
+
it 'rejects lists in custom_attributes' do
|
110
110
|
user = Intercom::User.new
|
111
111
|
|
112
112
|
_(proc { user.custom_attributes['thing'] = [1] }).must_raise(ArgumentError)
|
113
|
-
_(proc { user.custom_attributes['thing'] = { 1 => 2 } }).must_raise(ArgumentError)
|
114
|
-
_(proc { user.custom_attributes['thing'] = { 1 => { 2 => 3 } } }).must_raise(ArgumentError)
|
115
113
|
|
116
114
|
user = Intercom::User.from_api(test_user)
|
117
115
|
_(proc { user.custom_attributes['thing'] = [1] }).must_raise(ArgumentError)
|
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.2.
|
4
|
+
version: 4.2.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:
|
18
|
+
date: 2025-09-01 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: minitest
|
@@ -65,14 +65,14 @@ dependencies:
|
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '2.0'
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '2.0'
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: fakeweb
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
@@ -264,7 +264,7 @@ homepage: https://www.intercom.io
|
|
264
264
|
licenses:
|
265
265
|
- MIT
|
266
266
|
metadata: {}
|
267
|
-
post_install_message:
|
267
|
+
post_install_message:
|
268
268
|
rdoc_options: []
|
269
269
|
require_paths:
|
270
270
|
- lib
|
@@ -279,8 +279,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
279
279
|
- !ruby/object:Gem::Version
|
280
280
|
version: '0'
|
281
281
|
requirements: []
|
282
|
-
rubygems_version: 3.
|
283
|
-
signing_key:
|
282
|
+
rubygems_version: 3.0.3.1
|
283
|
+
signing_key:
|
284
284
|
specification_version: 4
|
285
285
|
summary: Ruby bindings for the Intercom API
|
286
286
|
test_files:
|