cogniteev-intercom 2.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.travis.yml +6 -0
- data/Gemfile +13 -0
- data/MIT-LICENSE +21 -0
- data/README.md +378 -0
- data/Rakefile +21 -0
- data/changes.txt +168 -0
- data/intercom.gemspec +28 -0
- data/lib/data/cacert.pem +3965 -0
- data/lib/ext/sliceable_hash.rb +16 -0
- data/lib/intercom.rb +176 -0
- data/lib/intercom/admin.rb +9 -0
- data/lib/intercom/api_operations/convert.rb +19 -0
- data/lib/intercom/api_operations/count.rb +16 -0
- data/lib/intercom/api_operations/delete.rb +15 -0
- data/lib/intercom/api_operations/find.rb +23 -0
- data/lib/intercom/api_operations/find_all.rb +33 -0
- data/lib/intercom/api_operations/list.rb +17 -0
- data/lib/intercom/api_operations/load.rb +16 -0
- data/lib/intercom/api_operations/save.rb +51 -0
- data/lib/intercom/collection_proxy.rb +71 -0
- data/lib/intercom/company.rb +29 -0
- data/lib/intercom/contact.rb +22 -0
- data/lib/intercom/conversation.rb +17 -0
- data/lib/intercom/count.rb +21 -0
- data/lib/intercom/errors.rb +61 -0
- data/lib/intercom/event.rb +11 -0
- data/lib/intercom/extended_api_operations/reply.rb +16 -0
- data/lib/intercom/extended_api_operations/tags.rb +14 -0
- data/lib/intercom/extended_api_operations/users.rb +17 -0
- data/lib/intercom/generic_handlers/base_handler.rb +22 -0
- data/lib/intercom/generic_handlers/count.rb +59 -0
- data/lib/intercom/generic_handlers/tag.rb +71 -0
- data/lib/intercom/generic_handlers/tag_find_all.rb +47 -0
- data/lib/intercom/lib/dynamic_accessors.rb +59 -0
- data/lib/intercom/lib/dynamic_accessors_on_method_missing.rb +53 -0
- data/lib/intercom/lib/flat_store.rb +31 -0
- data/lib/intercom/lib/typed_json_deserializer.rb +53 -0
- data/lib/intercom/message.rb +9 -0
- data/lib/intercom/note.rb +17 -0
- data/lib/intercom/notification.rb +20 -0
- data/lib/intercom/request.rb +166 -0
- data/lib/intercom/segment.rb +14 -0
- data/lib/intercom/subscription.rb +15 -0
- data/lib/intercom/tag.rb +23 -0
- data/lib/intercom/traits/api_resource.rb +132 -0
- data/lib/intercom/traits/dirty_tracking.rb +33 -0
- data/lib/intercom/traits/generic_handler_binding.rb +29 -0
- data/lib/intercom/traits/incrementable_attributes.rb +12 -0
- data/lib/intercom/user.rb +30 -0
- data/lib/intercom/utils.rb +62 -0
- data/lib/intercom/version.rb +3 -0
- data/spec/spec_helper.rb +308 -0
- data/spec/unit/intercom/admin_spec.rb +9 -0
- data/spec/unit/intercom/collection_proxy_spec.rb +34 -0
- data/spec/unit/intercom/company_spec.rb +23 -0
- data/spec/unit/intercom/contact_spec.rb +25 -0
- data/spec/unit/intercom/event_spec.rb +25 -0
- data/spec/unit/intercom/lib/flat_store_spec.rb +29 -0
- data/spec/unit/intercom/message_spec.rb +21 -0
- data/spec/unit/intercom/note_spec.rb +19 -0
- data/spec/unit/intercom/notification_spec.rb +68 -0
- data/spec/unit/intercom/request_spec.rb +16 -0
- data/spec/unit/intercom/subscription_spec.rb +18 -0
- data/spec/unit/intercom/tag_spec.rb +23 -0
- data/spec/unit/intercom/traits/api_resource_spec.rb +85 -0
- data/spec/unit/intercom/user_spec.rb +230 -0
- data/spec/unit/intercom_spec.rb +90 -0
- metadata +214 -0
@@ -0,0 +1,90 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Intercom do
|
4
|
+
it "has a version number" do
|
5
|
+
Intercom::VERSION.must_match(/\d+\.\d+\.\d+/)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "API" do
|
9
|
+
before do
|
10
|
+
Intercom.app_id = "abc123"
|
11
|
+
Intercom.app_api_key = "super-secret-key"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "raises ArgumentError if no app_id or app_api_key specified" do
|
15
|
+
Intercom.app_id = nil
|
16
|
+
Intercom.app_api_key = nil
|
17
|
+
proc { Intercom.target_base_url }.must_raise ArgumentError, "You must set both Intercom.app_id and Intercom.app_api_key to use this client. See https://github.com/intercom/intercom-ruby for usage examples."
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'raises an Intercom::MultipleMatchingUsers error when receiving a conflict' do
|
21
|
+
multiple_matching_error = { 'type' => 'error.list', 'errors' => [{ 'code' => 'conflict', 'message' => 'Multiple existing users match this email address - must be more specific using user_id' }]}
|
22
|
+
proc {Intercom::Request.new('/users', :get).raise_application_errors_on_failure(multiple_matching_error, 400)}.must_raise(Intercom::MultipleMatchingUsersError)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns the app_id and app_api_key previously set" do
|
26
|
+
Intercom.app_id.must_equal "abc123"
|
27
|
+
Intercom.app_api_key.must_equal "super-secret-key"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "defaults to https to api.intercom.io" do
|
31
|
+
Intercom.target_base_url.must_equal "https://abc123:super-secret-key@api.intercom.io"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "raises ResourceNotFound if get a 404" do
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "overriding protocol/hostname" do
|
39
|
+
before do
|
40
|
+
@protocol = Intercom.protocol
|
41
|
+
@hostname = Intercom.hostname
|
42
|
+
Intercom.endpoints = nil
|
43
|
+
end
|
44
|
+
|
45
|
+
after do
|
46
|
+
Intercom.protocol = @protocol
|
47
|
+
Intercom.hostname = @hostname
|
48
|
+
Intercom.endpoints = ["https://api.intercom.io"]
|
49
|
+
end
|
50
|
+
|
51
|
+
it "allows overriding of the endpoint and protocol" do
|
52
|
+
Intercom.protocol = "http"
|
53
|
+
Intercom.hostname = "localhost:3000"
|
54
|
+
Intercom.target_base_url.must_equal "http://abc123:super-secret-key@localhost:3000"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "prefers endpoints" do
|
58
|
+
Intercom.endpoint = "https://localhost:7654"
|
59
|
+
Intercom.target_base_url.must_equal "https://abc123:super-secret-key@localhost:7654"
|
60
|
+
Intercom.endpoints = unshuffleable_array(["http://example.com","https://localhost:7654"])
|
61
|
+
Intercom.target_base_url.must_equal "http://abc123:super-secret-key@example.com"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "has endpoints" do
|
65
|
+
Intercom.endpoints.must_equal ["https://api.intercom.io"]
|
66
|
+
Intercom.endpoints = ["http://example.com","https://localhost:7654"]
|
67
|
+
Intercom.endpoints.must_equal ["http://example.com","https://localhost:7654"]
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should randomize endpoints if last checked endpoint is > 5 minutes ago" do
|
71
|
+
Intercom.instance_variable_set(:@current_endpoint, "http://start")
|
72
|
+
Intercom.instance_variable_set(:@endpoints, ["http://alternative"])
|
73
|
+
Intercom.instance_variable_set(:@endpoint_randomized_at, Time.now - 120)
|
74
|
+
Intercom.current_endpoint.must_equal "http://start"
|
75
|
+
Intercom.instance_variable_set(:@endpoint_randomized_at, Time.now - 360)
|
76
|
+
Intercom.current_endpoint.must_equal "http://alternative"
|
77
|
+
Intercom.instance_variable_get(:@endpoint_randomized_at).to_i.must_be_close_to Time.now.to_i
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
it "checks for email or user id" do
|
84
|
+
proc { Intercom.check_required_params("else") }.must_raise ArgumentError, "Expected params Hash, got String"
|
85
|
+
proc { Intercom.check_required_params(:something => "else") }.must_raise ArgumentError, "Either email or user_id must be specified"
|
86
|
+
Intercom.check_required_params(:email => "bob@example.com", :something => "else")
|
87
|
+
Intercom.check_required_params("email" => "bob@example.com", :something => "else")
|
88
|
+
Intercom.check_required_params(:user_id => "123")
|
89
|
+
end
|
90
|
+
end
|
metadata
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cogniteev-intercom
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.5.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben McRedmond
|
8
|
+
- Ciaran Lee
|
9
|
+
- Darragh Curran
|
10
|
+
- Jeff Gardner
|
11
|
+
- Kyle Daigle
|
12
|
+
- Declan McGrath
|
13
|
+
- Jamie Osler
|
14
|
+
- Bob Long
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
date: 2016-06-22 00:00:00.000000000 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: minitest
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.4'
|
27
|
+
type: :development
|
28
|
+
prerelease: false
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.4'
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: rake
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.3'
|
41
|
+
type: :development
|
42
|
+
prerelease: false
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.3'
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: mocha
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: fakeweb
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
type: :development
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.3'
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: json
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.8'
|
83
|
+
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.8'
|
90
|
+
description: 'Intercom (https://www.intercom.io) is a customer relationship management
|
91
|
+
and messaging tool for web app owners. This library wraps the api provided by Intercom.
|
92
|
+
See http://docs.intercom.io/api for more details. '
|
93
|
+
email:
|
94
|
+
- ben@intercom.io
|
95
|
+
- ciaran@intercom.io
|
96
|
+
- darragh@intercom.io
|
97
|
+
- jeff@intercom.io
|
98
|
+
- kyle@digitalworkbox.com
|
99
|
+
- declan@intercom.io
|
100
|
+
- jamie@intercom.io
|
101
|
+
- bob@intercom.io
|
102
|
+
executables: []
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- .gitignore
|
107
|
+
- .travis.yml
|
108
|
+
- Gemfile
|
109
|
+
- MIT-LICENSE
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- changes.txt
|
113
|
+
- intercom.gemspec
|
114
|
+
- lib/data/cacert.pem
|
115
|
+
- lib/ext/sliceable_hash.rb
|
116
|
+
- lib/intercom.rb
|
117
|
+
- lib/intercom/admin.rb
|
118
|
+
- lib/intercom/api_operations/convert.rb
|
119
|
+
- lib/intercom/api_operations/count.rb
|
120
|
+
- lib/intercom/api_operations/delete.rb
|
121
|
+
- lib/intercom/api_operations/find.rb
|
122
|
+
- lib/intercom/api_operations/find_all.rb
|
123
|
+
- lib/intercom/api_operations/list.rb
|
124
|
+
- lib/intercom/api_operations/load.rb
|
125
|
+
- lib/intercom/api_operations/save.rb
|
126
|
+
- lib/intercom/collection_proxy.rb
|
127
|
+
- lib/intercom/company.rb
|
128
|
+
- lib/intercom/contact.rb
|
129
|
+
- lib/intercom/conversation.rb
|
130
|
+
- lib/intercom/count.rb
|
131
|
+
- lib/intercom/errors.rb
|
132
|
+
- lib/intercom/event.rb
|
133
|
+
- lib/intercom/extended_api_operations/reply.rb
|
134
|
+
- lib/intercom/extended_api_operations/tags.rb
|
135
|
+
- lib/intercom/extended_api_operations/users.rb
|
136
|
+
- lib/intercom/generic_handlers/base_handler.rb
|
137
|
+
- lib/intercom/generic_handlers/count.rb
|
138
|
+
- lib/intercom/generic_handlers/tag.rb
|
139
|
+
- lib/intercom/generic_handlers/tag_find_all.rb
|
140
|
+
- lib/intercom/lib/dynamic_accessors.rb
|
141
|
+
- lib/intercom/lib/dynamic_accessors_on_method_missing.rb
|
142
|
+
- lib/intercom/lib/flat_store.rb
|
143
|
+
- lib/intercom/lib/typed_json_deserializer.rb
|
144
|
+
- lib/intercom/message.rb
|
145
|
+
- lib/intercom/note.rb
|
146
|
+
- lib/intercom/notification.rb
|
147
|
+
- lib/intercom/request.rb
|
148
|
+
- lib/intercom/segment.rb
|
149
|
+
- lib/intercom/subscription.rb
|
150
|
+
- lib/intercom/tag.rb
|
151
|
+
- lib/intercom/traits/api_resource.rb
|
152
|
+
- lib/intercom/traits/dirty_tracking.rb
|
153
|
+
- lib/intercom/traits/generic_handler_binding.rb
|
154
|
+
- lib/intercom/traits/incrementable_attributes.rb
|
155
|
+
- lib/intercom/user.rb
|
156
|
+
- lib/intercom/utils.rb
|
157
|
+
- lib/intercom/version.rb
|
158
|
+
- spec/spec_helper.rb
|
159
|
+
- spec/unit/intercom/admin_spec.rb
|
160
|
+
- spec/unit/intercom/collection_proxy_spec.rb
|
161
|
+
- spec/unit/intercom/company_spec.rb
|
162
|
+
- spec/unit/intercom/contact_spec.rb
|
163
|
+
- spec/unit/intercom/event_spec.rb
|
164
|
+
- spec/unit/intercom/lib/flat_store_spec.rb
|
165
|
+
- spec/unit/intercom/message_spec.rb
|
166
|
+
- spec/unit/intercom/note_spec.rb
|
167
|
+
- spec/unit/intercom/notification_spec.rb
|
168
|
+
- spec/unit/intercom/request_spec.rb
|
169
|
+
- spec/unit/intercom/subscription_spec.rb
|
170
|
+
- spec/unit/intercom/tag_spec.rb
|
171
|
+
- spec/unit/intercom/traits/api_resource_spec.rb
|
172
|
+
- spec/unit/intercom/user_spec.rb
|
173
|
+
- spec/unit/intercom_spec.rb
|
174
|
+
homepage: https://www.intercom.io
|
175
|
+
licenses:
|
176
|
+
- MIT
|
177
|
+
metadata: {}
|
178
|
+
post_install_message:
|
179
|
+
rdoc_options: []
|
180
|
+
require_paths:
|
181
|
+
- lib
|
182
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - '>='
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: 1.9.3
|
187
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - '>='
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
requirements: []
|
193
|
+
rubyforge_project:
|
194
|
+
rubygems_version: 2.0.14
|
195
|
+
signing_key:
|
196
|
+
specification_version: 4
|
197
|
+
summary: Ruby bindings for the Intercom API
|
198
|
+
test_files:
|
199
|
+
- spec/spec_helper.rb
|
200
|
+
- spec/unit/intercom/admin_spec.rb
|
201
|
+
- spec/unit/intercom/collection_proxy_spec.rb
|
202
|
+
- spec/unit/intercom/company_spec.rb
|
203
|
+
- spec/unit/intercom/contact_spec.rb
|
204
|
+
- spec/unit/intercom/event_spec.rb
|
205
|
+
- spec/unit/intercom/lib/flat_store_spec.rb
|
206
|
+
- spec/unit/intercom/message_spec.rb
|
207
|
+
- spec/unit/intercom/note_spec.rb
|
208
|
+
- spec/unit/intercom/notification_spec.rb
|
209
|
+
- spec/unit/intercom/request_spec.rb
|
210
|
+
- spec/unit/intercom/subscription_spec.rb
|
211
|
+
- spec/unit/intercom/tag_spec.rb
|
212
|
+
- spec/unit/intercom/traits/api_resource_spec.rb
|
213
|
+
- spec/unit/intercom/user_spec.rb
|
214
|
+
- spec/unit/intercom_spec.rb
|