intercom 3.5.10 → 4.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +35 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +5 -0
- data/Gemfile +1 -4
- data/README.md +418 -216
- data/RELEASING.md +9 -0
- data/Rakefile +1 -1
- data/changes.txt +141 -0
- data/intercom.gemspec +1 -2
- data/lib/intercom.rb +34 -19
- data/lib/intercom/api_operations/archive.rb +16 -0
- data/lib/intercom/api_operations/delete.rb +4 -1
- data/lib/intercom/api_operations/find.rb +5 -2
- data/lib/intercom/api_operations/find_all.rb +4 -3
- data/lib/intercom/api_operations/list.rb +4 -1
- data/lib/intercom/api_operations/load.rb +4 -2
- data/lib/intercom/api_operations/nested_resource.rb +70 -0
- data/lib/intercom/api_operations/request_hard_delete.rb +12 -0
- data/lib/intercom/api_operations/save.rb +6 -4
- data/lib/intercom/api_operations/scroll.rb +4 -5
- data/lib/intercom/api_operations/search.rb +18 -0
- data/lib/intercom/article.rb +7 -0
- data/lib/intercom/base_collection_proxy.rb +72 -0
- data/lib/intercom/client.rb +66 -18
- data/lib/intercom/client_collection_proxy.rb +17 -39
- data/lib/intercom/collection.rb +7 -0
- data/lib/intercom/company.rb +8 -0
- data/lib/intercom/contact.rb +22 -3
- data/lib/intercom/conversation.rb +5 -0
- data/lib/intercom/data_attribute.rb +7 -0
- data/lib/intercom/deprecated_leads_collection_proxy.rb +22 -0
- data/lib/intercom/deprecated_resources.rb +13 -0
- data/lib/intercom/errors.rb +44 -4
- data/lib/intercom/extended_api_operations/segments.rb +3 -1
- data/lib/intercom/extended_api_operations/tags.rb +3 -1
- data/lib/intercom/lead.rb +21 -0
- data/lib/intercom/lib/typed_json_deserializer.rb +42 -37
- data/lib/intercom/note.rb +4 -0
- data/lib/intercom/request.rb +162 -95
- data/lib/intercom/scroll_collection_proxy.rb +38 -42
- data/lib/intercom/search_collection_proxy.rb +47 -0
- data/lib/intercom/section.rb +23 -0
- data/lib/intercom/segment.rb +4 -0
- data/lib/intercom/service/article.rb +20 -0
- data/lib/intercom/service/base_service.rb +13 -0
- data/lib/intercom/service/collection.rb +24 -0
- data/lib/intercom/service/company.rb +4 -2
- data/lib/intercom/service/contact.rb +29 -6
- data/lib/intercom/service/conversation.rb +23 -2
- data/lib/intercom/service/data_attribute.rb +20 -0
- data/lib/intercom/service/event.rb +12 -0
- data/lib/intercom/service/lead.rb +41 -0
- data/lib/intercom/service/note.rb +4 -8
- data/lib/intercom/service/section.rb +7 -0
- data/lib/intercom/service/tag.rb +8 -8
- data/lib/intercom/service/team.rb +17 -0
- data/lib/intercom/service/user.rb +4 -2
- data/lib/intercom/service/visitor.rb +15 -6
- data/lib/intercom/tag.rb +4 -0
- data/lib/intercom/team.rb +7 -0
- data/lib/intercom/traits/api_resource.rb +48 -27
- data/lib/intercom/traits/dirty_tracking.rb +8 -1
- data/lib/intercom/user.rb +12 -3
- data/lib/intercom/utils.rb +13 -2
- data/lib/intercom/version.rb +1 -1
- data/lib/intercom/visitor.rb +0 -2
- data/spec/spec_helper.rb +881 -436
- data/spec/unit/intercom/admin_spec.rb +2 -2
- data/spec/unit/intercom/article_spec.rb +40 -0
- data/spec/unit/intercom/base_collection_proxy_spec.rb +30 -0
- data/spec/unit/intercom/client_collection_proxy_spec.rb +41 -41
- data/spec/unit/intercom/client_spec.rb +76 -9
- data/spec/unit/intercom/collection_spec.rb +32 -0
- data/spec/unit/intercom/company_spec.rb +29 -21
- data/spec/unit/intercom/contact_spec.rb +365 -29
- data/spec/unit/intercom/conversation_spec.rb +70 -7
- data/spec/unit/intercom/count_spec.rb +4 -4
- data/spec/unit/intercom/data_attribute_spec.rb +40 -0
- data/spec/unit/intercom/deprecated_leads_collection_proxy_spec.rb +17 -0
- data/spec/unit/intercom/event_spec.rb +25 -8
- data/spec/unit/intercom/job_spec.rb +24 -24
- data/spec/unit/intercom/lead_spec.rb +57 -0
- data/spec/unit/intercom/lib/flat_store_spec.rb +22 -20
- data/spec/unit/intercom/message_spec.rb +1 -1
- data/spec/unit/intercom/note_spec.rb +4 -10
- data/spec/unit/intercom/request_spec.rb +150 -9
- data/spec/unit/intercom/scroll_collection_proxy_spec.rb +40 -39
- data/spec/unit/intercom/search_collection_proxy_spec.rb +60 -0
- data/spec/unit/intercom/section_spec.rb +32 -0
- data/spec/unit/intercom/segment_spec.rb +2 -2
- data/spec/unit/intercom/subscription_spec.rb +5 -6
- data/spec/unit/intercom/tag_spec.rb +22 -14
- data/spec/unit/intercom/team_spec.rb +21 -0
- data/spec/unit/intercom/traits/api_resource_spec.rb +129 -47
- data/spec/unit/intercom/user_spec.rb +227 -217
- data/spec/unit/intercom/visitor_spec.rb +49 -0
- data/spec/unit/intercom_spec.rb +5 -3
- metadata +63 -26
- data/.travis.yml +0 -6
- data/lib/intercom/extended_api_operations/users.rb +0 -16
- data/spec/unit/intercom/visitors_spec.rb +0 -61
data/lib/intercom/version.rb
CHANGED
data/lib/intercom/visitor.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,126 +1,243 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'intercom'
|
2
4
|
require 'minitest/autorun'
|
3
5
|
require 'mocha/setup'
|
6
|
+
require 'webmock'
|
7
|
+
require 'time'
|
8
|
+
require 'pry'
|
9
|
+
include WebMock::API
|
10
|
+
|
11
|
+
def test_article
|
12
|
+
{
|
13
|
+
"id": "1",
|
14
|
+
"type": "article",
|
15
|
+
"workspace_id": "tx2p130c",
|
16
|
+
"title": "new title",
|
17
|
+
"description": "test Finished articles are visible when they're added to a Help Center collection",
|
18
|
+
"body": "<p>thingbop</p>",
|
19
|
+
"author_id": 1,
|
20
|
+
"state": "draft"
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_updated_article
|
25
|
+
{
|
26
|
+
"id": "1",
|
27
|
+
"type": "article",
|
28
|
+
"workspace_id": "tx2p130c",
|
29
|
+
"title": "new updated title",
|
30
|
+
"description": "test Finished articles are visible when they're added to a Help Center collection",
|
31
|
+
"body": "<p>thingbop</p>",
|
32
|
+
"author_id": 1,
|
33
|
+
"state": "draft"
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_user(email = 'bob@example.com')
|
38
|
+
{
|
39
|
+
'type' => 'user',
|
40
|
+
'id' => 'aaaaaaaaaaaaaaaaaaaaaaaa',
|
41
|
+
'user_id' => 'id-from-customers-app',
|
42
|
+
'email' => email,
|
43
|
+
'name' => 'Joe Schmoe',
|
44
|
+
'avatar' => { 'type' => 'avatar', 'image_url' => 'https://graph.facebook.com/1/picture?width=24&height=24' },
|
45
|
+
'app_id' => 'the-app-id',
|
46
|
+
'custom_attributes' => { 'a' => 'b', 'b' => 2 },
|
47
|
+
'companies' =>
|
48
|
+
{ 'type' => 'company.list',
|
49
|
+
'companies' =>
|
50
|
+
[{ 'type' => 'company',
|
51
|
+
'company_id' => '123',
|
52
|
+
'id' => 'bbbbbbbbbbbbbbbbbbbbbbbb',
|
53
|
+
'app_id' => 'the-app-id',
|
54
|
+
'name' => 'Company 1',
|
55
|
+
'remote_created_at' => 1_390_936_440,
|
56
|
+
'created_at' => 1_401_970_114,
|
57
|
+
'updated_at' => 1_401_970_114,
|
58
|
+
'last_request_at' => 1_401_970_113,
|
59
|
+
'monthly_spend' => 0,
|
60
|
+
'session_count' => 0,
|
61
|
+
'user_count' => 1,
|
62
|
+
'tag_ids' => [],
|
63
|
+
'custom_attributes' => { 'category' => 'Tech' } }] },
|
64
|
+
'session_count' => 123,
|
65
|
+
'unsubscribed_from_emails' => true,
|
66
|
+
'last_request_at' => 1_401_970_113,
|
67
|
+
'created_at' => 1_401_970_114,
|
68
|
+
'remote_created_at' => 1_393_613_864,
|
69
|
+
'updated_at' => 1_401_970_114,
|
70
|
+
'user_agent_data' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
|
71
|
+
'social_profiles' => { 'type' => 'social_profile.list',
|
72
|
+
'social_profiles' => [
|
73
|
+
{ 'type' => 'social_profile', 'name' => 'twitter', 'url' => 'http://twitter.com/abc', 'username' => 'abc', 'id' => nil },
|
74
|
+
{ 'type' => 'social_profile', 'name' => 'twitter', 'username' => 'abc2', 'url' => 'http://twitter.com/abc2', 'id' => nil },
|
75
|
+
{ 'type' => 'social_profile', 'name' => 'facebook', 'url' => 'http://facebook.com/abc', 'username' => 'abc', 'id' => '1234242' },
|
76
|
+
{ 'type' => 'social_profile', 'name' => 'quora', 'url' => 'http://facebook.com/abc', 'username' => 'abc', 'id' => '1234242' }
|
77
|
+
] },
|
78
|
+
'location_data' =>
|
79
|
+
{ 'type' => 'location_data',
|
80
|
+
'city_name' => 'Dublin',
|
81
|
+
'continent_code' => 'EU',
|
82
|
+
'country_name' => 'Ireland',
|
83
|
+
'latitude' => '90',
|
84
|
+
'longitude' => '10',
|
85
|
+
'postal_code' => 'IE',
|
86
|
+
'region_name' => 'Europe',
|
87
|
+
'timezone' => '+1000',
|
88
|
+
'country_code' => 'IRL' }
|
89
|
+
}
|
90
|
+
end
|
4
91
|
|
5
|
-
def
|
6
|
-
{
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
92
|
+
def test_contact(email = 'bob@example.com', role = 'user')
|
93
|
+
{
|
94
|
+
'type' => 'contact',
|
95
|
+
'id' => 'aaaaaaaaaaaaaaaaaaaaaaaa',
|
96
|
+
'external_id' => 'id-from-customers-app',
|
97
|
+
'role' => role,
|
98
|
+
'email' => email,
|
99
|
+
'name' => 'Joe Schmoe',
|
100
|
+
'avatar' => { 'type' => 'avatar', 'image_url' => 'https://graph.facebook.com/1/picture?width=24&height=24' },
|
101
|
+
'workspace_id' => 'the-workspace-id',
|
102
|
+
'custom_attributes' => { 'a' => 'b', 'b' => 2 },
|
103
|
+
'companies' => {
|
104
|
+
'type' => 'list',
|
105
|
+
'data' =>
|
106
|
+
[{ 'type' => 'company',
|
107
|
+
'company_id' => '123',
|
108
|
+
'id' => 'bbbbbbbbbbbbbbbbbbbbbbbb',
|
109
|
+
'workspace_id' => 'the-workspace-id',
|
110
|
+
'name' => 'Company 1',
|
111
|
+
'remote_created_at' => 1_390_936_440,
|
112
|
+
'created_at' => 1_401_970_114,
|
113
|
+
'updated_at' => 1_401_970_114,
|
114
|
+
'last_request_at' => 1_401_970_113,
|
115
|
+
'monthly_spend' => 0,
|
116
|
+
'session_count' => 0,
|
117
|
+
'contact_count' => 1,
|
118
|
+
'tag_ids' => [],
|
119
|
+
'custom_attributes' => { 'category' => 'Tech' } }],
|
120
|
+
'url' => '/contacts/12345/companies'
|
121
|
+
},
|
122
|
+
'tags' => {
|
123
|
+
'type' => 'list',
|
124
|
+
'data' => [],
|
125
|
+
'url' => '/contacts/12345/tags'
|
126
|
+
},
|
127
|
+
'notes' => {
|
128
|
+
'type' => 'list',
|
129
|
+
'data' => [],
|
130
|
+
'url' => '/contacts/12345/notes'
|
131
|
+
},
|
132
|
+
'session_count' => 123,
|
133
|
+
'unsubscribed_from_emails' => true,
|
134
|
+
'last_request_at' => 1_401_970_113,
|
135
|
+
'created_at' => 1_401_970_114,
|
136
|
+
'remote_created_at' => 1_393_613_864,
|
137
|
+
'updated_at' => 1_401_970_114,
|
138
|
+
'user_agent_data' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
|
139
|
+
'social_profiles' => { 'type' => 'social_profile.list',
|
140
|
+
'social_profiles' => [
|
141
|
+
{ 'type' => 'social_profile', 'name' => 'twitter', 'url' => 'http://twitter.com/abc', 'username' => 'abc', 'id' => nil },
|
142
|
+
{ 'type' => 'social_profile', 'name' => 'twitter', 'username' => 'abc2', 'url' => 'http://twitter.com/abc2', 'id' => nil },
|
143
|
+
{ 'type' => 'social_profile', 'name' => 'facebook', 'url' => 'http://facebook.com/abc', 'username' => 'abc', 'id' => '1234242' },
|
144
|
+
{ 'type' => 'social_profile', 'name' => 'quora', 'url' => 'http://facebook.com/abc', 'username' => 'abc', 'id' => '1234242' }
|
145
|
+
] },
|
146
|
+
'location_data' =>
|
147
|
+
{ 'type' => 'location_data',
|
148
|
+
'city_name' => 'Dublin',
|
149
|
+
'continent_code' => 'EU',
|
150
|
+
'country_name' => 'Ireland',
|
151
|
+
'latitude' => '90',
|
152
|
+
'longitude' => '10',
|
153
|
+
'postal_code' => 'IE',
|
154
|
+
'region_name' => 'Europe',
|
155
|
+
'timezone' => '+1000',
|
156
|
+
'country_code' => 'IRL' }
|
157
|
+
}
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_collection
|
161
|
+
{
|
162
|
+
'id' => '1',
|
163
|
+
'workspace_id' => 'tx2p130c',
|
164
|
+
'name' => 'Collection 1',
|
165
|
+
'url' => 'http://www.intercom.test/help/',
|
166
|
+
'order' => 1,
|
167
|
+
'type' => 'collection',
|
168
|
+
'description' => 'Collection desc',
|
169
|
+
'icon' => 'book-bookmark'
|
170
|
+
}
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_collection_list
|
174
|
+
{
|
175
|
+
'type' => 'list',
|
176
|
+
'total_count' => 1,
|
177
|
+
'pages' => {
|
178
|
+
'page' => 1,
|
179
|
+
'per_page' => 20,
|
180
|
+
'total_pages' => 1
|
181
|
+
},
|
182
|
+
'data' => [{
|
183
|
+
'id' => '1',
|
184
|
+
'workspace_id' => 'tx2p130c',
|
185
|
+
'name' => 'Collection 1',
|
186
|
+
'url' => 'http://www.intercom.test/help/',
|
187
|
+
'order' => 1,
|
188
|
+
'type' => 'collection',
|
189
|
+
'description' => 'Collection desc',
|
190
|
+
'icon' => 'book-bookmark'
|
191
|
+
}]
|
192
|
+
}
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_visitor
|
196
|
+
{
|
197
|
+
'type' => 'visitor',
|
198
|
+
'id' => '123',
|
199
|
+
'user_id' => '12334',
|
200
|
+
'anonymous' => true,
|
201
|
+
'email' => nil,
|
202
|
+
'phone' => nil,
|
203
|
+
'name' => nil,
|
204
|
+
'pseudonym' => nil,
|
205
|
+
'app_id' => 'abcd1234',
|
206
|
+
'companies' => { 'type' => 'company.list', 'companies' => [] },
|
207
|
+
'location_data' => {},
|
208
|
+
'last_request_at' => nil,
|
209
|
+
'created_at' => 1_401_970_114,
|
210
|
+
'remote_created_at' => 1_401_970_114,
|
211
|
+
'signed_up_at' => 1_401_970_114,
|
212
|
+
'updated_at' => 1_401_970_114,
|
213
|
+
'session_count' => 0,
|
214
|
+
'social_profiles' => { 'type' => 'social_profile.list', 'social_profiles' => [] },
|
215
|
+
'owner_id' => nil,
|
216
|
+
'unsubscribed_from_emails' => false,
|
217
|
+
'marked_email_as_spam' => false,
|
218
|
+
'has_hard_bounced' => false,
|
219
|
+
'tags' => { 'type' => 'tag.list', 'tags' => [] },
|
220
|
+
'segments' => { 'type' => 'segment.list', 'segments' => [] },
|
221
|
+
'custom_attributes' => {},
|
222
|
+
'referrer' => nil,
|
223
|
+
'utm_campaign' => nil,
|
224
|
+
'utm_content' => nil,
|
225
|
+
'utm_medium' => nil,
|
226
|
+
'utm_source' => nil,
|
227
|
+
'utm_term' => nil,
|
228
|
+
'do_not_track' => nil
|
112
229
|
}
|
113
230
|
end
|
114
231
|
|
115
232
|
def test_admin_list
|
116
233
|
{
|
117
|
-
|
118
|
-
|
234
|
+
'type' => 'admin.list',
|
235
|
+
'admins' => [
|
119
236
|
{
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
237
|
+
'type' => 'admin',
|
238
|
+
'id' => '1234',
|
239
|
+
'name' => 'Hoban Washburne',
|
240
|
+
'email' => 'wash@serenity.io'
|
124
241
|
}
|
125
242
|
]
|
126
243
|
}
|
@@ -128,34 +245,88 @@ end
|
|
128
245
|
|
129
246
|
def test_admin
|
130
247
|
{
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
248
|
+
'type' => 'admin',
|
249
|
+
'id' => '1234',
|
250
|
+
'name' => 'Hoban Washburne',
|
251
|
+
'email' => 'wash@serenity.io'
|
252
|
+
}
|
253
|
+
end
|
254
|
+
|
255
|
+
def test_team_list
|
256
|
+
{
|
257
|
+
'type' => 'team.list',
|
258
|
+
'teams' => [
|
259
|
+
{
|
260
|
+
'type' => 'team',
|
261
|
+
'id' => '2744328',
|
262
|
+
'name' => 'the_a_team',
|
263
|
+
'admin_ids' => [646_303, 814_860]
|
264
|
+
},
|
265
|
+
{
|
266
|
+
'type' => 'team',
|
267
|
+
'id' => '814865',
|
268
|
+
'name' => 'BA_App',
|
269
|
+
'admin_ids' => [492_881, 1_195_856]
|
270
|
+
}
|
271
|
+
]
|
272
|
+
}
|
273
|
+
end
|
274
|
+
|
275
|
+
def test_team
|
276
|
+
{
|
277
|
+
'type' => 'team',
|
278
|
+
'id' => '2744328',
|
279
|
+
'name' => 'the_a_team',
|
280
|
+
'admin_ids' => [646_303, 814_860]
|
281
|
+
}
|
282
|
+
end
|
283
|
+
|
284
|
+
def test_company(name = 'Blue Sun')
|
285
|
+
{
|
286
|
+
'type' => 'company',
|
287
|
+
'id' => '531ee472cce572a6ec000006',
|
288
|
+
'name' => name,
|
289
|
+
'plan' => {
|
290
|
+
'type' => 'plan',
|
291
|
+
'id' => '1',
|
292
|
+
'name' => 'Paid'
|
293
|
+
},
|
294
|
+
'company_id' => '6',
|
295
|
+
'remote_created_at' => 1_394_531_169,
|
296
|
+
'created_at' => 1_394_533_506,
|
297
|
+
'updated_at' => 1_396_874_658,
|
298
|
+
'last_request_at' => 1_396_874_658,
|
299
|
+
'monthly_spend' => 49,
|
300
|
+
'session_count' => 26,
|
301
|
+
'user_count' => 10,
|
302
|
+
'custom_attributes' => {
|
303
|
+
'paid_subscriber' => true,
|
304
|
+
'team_mates' => 0
|
305
|
+
}
|
135
306
|
}
|
136
307
|
end
|
137
308
|
|
138
|
-
def
|
309
|
+
def test_company_dates(name = 'Blue Sun', created_at = 1_401_970_114, last_request_at = 1_401_970_113)
|
139
310
|
{
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
311
|
+
'type' => 'company',
|
312
|
+
'id' => '531ee472cce572a6ec000006',
|
313
|
+
'name' => name,
|
314
|
+
'plan' => {
|
315
|
+
'type' => 'plan',
|
316
|
+
'id' => '1',
|
317
|
+
'name' => 'Paid'
|
147
318
|
},
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
319
|
+
'company_id' => '6',
|
320
|
+
'remote_created_at' => 1_394_531_169,
|
321
|
+
'created_at' => created_at,
|
322
|
+
'updated_at' => 1_396_874_658,
|
323
|
+
'last_request_at' => last_request_at,
|
324
|
+
'monthly_spend' => 49,
|
325
|
+
'session_count' => 26,
|
326
|
+
'user_count' => 10,
|
327
|
+
'custom_attributes' => {
|
328
|
+
'paid_subscriber' => true,
|
329
|
+
'team_mates' => 0
|
159
330
|
}
|
160
331
|
}
|
161
332
|
end
|
@@ -166,163 +337,327 @@ end
|
|
166
337
|
|
167
338
|
def test_message
|
168
339
|
{
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
},
|
195
|
-
"is_admin" => true
|
196
|
-
}
|
340
|
+
'created_at' => 1_329_837_506,
|
341
|
+
'updated_at' => 1_329_664_706,
|
342
|
+
'read' => true,
|
343
|
+
'created_by_user' => true,
|
344
|
+
'thread_id' => 5591,
|
345
|
+
'messages' => [
|
346
|
+
{
|
347
|
+
'created_at' => 1_329_837_506,
|
348
|
+
'html' => "<p>Hey Intercom, What is up?</p>\n",
|
349
|
+
'from' => {
|
350
|
+
'email' => 'bob@example.com',
|
351
|
+
'name' => 'Bob',
|
352
|
+
'user_id' => '123',
|
353
|
+
'is_admin' => false
|
354
|
+
}
|
355
|
+
},
|
356
|
+
{
|
357
|
+
'created_at' => 1_329_664_706,
|
358
|
+
'rendered_body' => "<p>Not much, you?</p>\n",
|
359
|
+
'from' => {
|
360
|
+
'name' => 'Super Duper Admin',
|
361
|
+
'avatar' => {
|
362
|
+
'square_25' => 'https://static.intercomcdn.com/avatars/13347/square_25/Ruairi_Profile.png?1375368166',
|
363
|
+
'square_50' => 'https://static.intercomcdn.com/avatars/13347/square_50/Ruairi_Profile.png?1375368166',
|
364
|
+
'square_128' => 'https://static.intercomcdn.com/avatars/13347/square_128/Ruairi_Profile.png?1375368166'
|
197
365
|
},
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
366
|
+
'is_admin' => true
|
367
|
+
}
|
368
|
+
},
|
369
|
+
{
|
370
|
+
'created_at' => 1_329_664_806,
|
371
|
+
'rendered_body' => "<p>Not much either :(</p>\n",
|
372
|
+
'from' => {
|
373
|
+
'email' => 'bob@example.com',
|
374
|
+
'name' => 'Bob',
|
375
|
+
'user_id' => '123',
|
376
|
+
'is_admin' => false
|
377
|
+
}
|
378
|
+
}
|
379
|
+
]
|
209
380
|
}
|
210
381
|
end
|
211
382
|
|
212
|
-
def page_of_users(include_next_link= false)
|
383
|
+
def page_of_users(include_next_link = false)
|
213
384
|
{
|
214
|
-
|
215
|
-
|
385
|
+
'type' => 'user.list',
|
386
|
+
'pages' =>
|
216
387
|
{
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
388
|
+
'type' => 'pages',
|
389
|
+
'next' => (include_next_link ? 'https://api.intercom.io/users?per_page=50&page=2' : nil),
|
390
|
+
'page' => 1,
|
391
|
+
'per_page' => 50,
|
392
|
+
'total_pages' => 7
|
222
393
|
},
|
223
|
-
|
224
|
-
|
394
|
+
'users' => [test_user('user1@example.com'), test_user('user2@example.com'), test_user('user3@example.com')],
|
395
|
+
'total_count' => 314
|
396
|
+
}
|
397
|
+
end
|
398
|
+
|
399
|
+
def page_of_contacts(include_starting_after = false)
|
400
|
+
{ 'type' => 'list',
|
401
|
+
'data' => [
|
402
|
+
{
|
403
|
+
'type' => 'contact',
|
404
|
+
'id' => '123',
|
405
|
+
'workspace_id' => 'abc',
|
406
|
+
'external_id' => '12345',
|
407
|
+
'role' => 'lead',
|
408
|
+
'email' => 'test1@example.com',
|
409
|
+
'name' => 'Test',
|
410
|
+
'unsubscribed_from_emails' => false,
|
411
|
+
'created_at' => 1_573_035_771,
|
412
|
+
'updated_at' => 1_573_035_771,
|
413
|
+
'custom_attributes' => {},
|
414
|
+
'tags' => {
|
415
|
+
'type' => 'list',
|
416
|
+
'data' => [],
|
417
|
+
'url' => '/contacts/12345/tags'
|
418
|
+
},
|
419
|
+
'notes' => {
|
420
|
+
'type' => 'list',
|
421
|
+
'data' => [],
|
422
|
+
'url' => '/contacts/12345/notes'
|
423
|
+
},
|
424
|
+
'companies' => {
|
425
|
+
'type' => 'list',
|
426
|
+
'data' => [],
|
427
|
+
'url' => '/contacts/12345/companies'
|
428
|
+
}
|
429
|
+
},
|
430
|
+
{
|
431
|
+
'type' => 'contact',
|
432
|
+
'id' => '321',
|
433
|
+
'workspace_id' => 'abc',
|
434
|
+
'external_id' => '54321',
|
435
|
+
'role' => 'user',
|
436
|
+
'email' => 'test2@example.com',
|
437
|
+
'name' => 'Test',
|
438
|
+
'unsubscribed_from_emails' => false,
|
439
|
+
'created_at' => 1_573_035_771,
|
440
|
+
'updated_at' => 1_573_035_771,
|
441
|
+
'custom_attributes' => {},
|
442
|
+
'tags' => {
|
443
|
+
'type' => 'list',
|
444
|
+
'data' => [],
|
445
|
+
'url' => '/contacts/54321/tags'
|
446
|
+
},
|
447
|
+
'notes' => {
|
448
|
+
'type' => 'list',
|
449
|
+
'data' => [],
|
450
|
+
'url' => '/contacts/54321/notes'
|
451
|
+
},
|
452
|
+
'companies' => {
|
453
|
+
'type' => 'list',
|
454
|
+
'data' => [],
|
455
|
+
'url' => '/contacts/54321/companies'
|
456
|
+
}
|
457
|
+
},
|
458
|
+
{
|
459
|
+
'type' => 'contact',
|
460
|
+
'id' => '111',
|
461
|
+
'workspace_id' => 'abc',
|
462
|
+
'external_id' => '111',
|
463
|
+
'role' => 'lead',
|
464
|
+
'email' => 'test3@example.com',
|
465
|
+
'name' => 'Test',
|
466
|
+
'unsubscribed_from_emails' => false,
|
467
|
+
'created_at' => 1_573_035_771,
|
468
|
+
'updated_at' => 1_573_035_771,
|
469
|
+
'custom_attributes' => {},
|
470
|
+
'tags' => {
|
471
|
+
'type' => 'list',
|
472
|
+
'data' => [],
|
473
|
+
'url' => '/contacts/111/tags'
|
474
|
+
},
|
475
|
+
'notes' => {
|
476
|
+
'type' => 'list',
|
477
|
+
'data' => [],
|
478
|
+
'url' => '/contacts/111/notes'
|
479
|
+
},
|
480
|
+
'companies' => {
|
481
|
+
'type' => 'list',
|
482
|
+
'data' => [],
|
483
|
+
'url' => '/contacts/111/companies'
|
484
|
+
}
|
485
|
+
}
|
486
|
+
],
|
487
|
+
'total_count' => 3,
|
488
|
+
'pages' => {
|
489
|
+
'type' => 'pages',
|
490
|
+
'next' => (include_starting_after ? { 'page' => 2, 'starting_after' => 'EnCrYpTeDsTrInG' } : nil),
|
491
|
+
'page' => 1,
|
492
|
+
'per_page' => 50,
|
493
|
+
'total_pages' => 1
|
494
|
+
} }
|
495
|
+
end
|
496
|
+
|
497
|
+
def page_of_companies(include_next_link = false)
|
498
|
+
{
|
499
|
+
'type' => 'company.list',
|
500
|
+
'pages' =>
|
501
|
+
{
|
502
|
+
'type' => 'pages',
|
503
|
+
'next' => (include_next_link ? 'https://api.intercom.io/companies?per_page=50&page=2' : nil),
|
504
|
+
'page' => 1,
|
505
|
+
'per_page' => 50,
|
506
|
+
'total_pages' => 7
|
507
|
+
},
|
508
|
+
'companies' => [test_company('company1'), test_company('company2'), test_company('company3')],
|
509
|
+
'total_count' => 314
|
225
510
|
}
|
226
511
|
end
|
227
512
|
|
228
|
-
def
|
513
|
+
def companies_scroll(include_companies = false)
|
229
514
|
{
|
230
|
-
|
231
|
-
|
232
|
-
|
515
|
+
'type' => 'company.list',
|
516
|
+
'scroll_param' => 'da6bbbac-25f6-4f07-866b-b911082d7',
|
517
|
+
'companies' => (include_companies ? [test_company('company1'), test_company('company2'), test_company('company3')] : [])
|
233
518
|
}
|
234
519
|
end
|
235
520
|
|
236
|
-
def
|
521
|
+
def companies_pagination(include_next_link:, per_page:, page:, total_pages:, total_count:, company_list:)
|
237
522
|
{
|
238
|
-
|
239
|
-
|
523
|
+
'type' => 'company.list',
|
524
|
+
'pages' =>
|
240
525
|
{
|
241
|
-
|
242
|
-
|
243
|
-
+ per_page.to_s +
|
244
|
-
|
245
|
-
|
246
|
-
|
526
|
+
'type' => 'pages',
|
527
|
+
'next' => (include_next_link ? 'https://api.intercom.io/companies?per_page=' \
|
528
|
+
+ per_page.to_s + '&page=' + (page + 1).to_s : nil),
|
529
|
+
'page' => page,
|
530
|
+
'per_page' => per_page,
|
531
|
+
'total_pages' => total_pages
|
247
532
|
},
|
248
|
-
|
249
|
-
|
533
|
+
'companies' => company_list,
|
534
|
+
'total_count' => total_count
|
250
535
|
}
|
251
536
|
end
|
252
537
|
|
253
538
|
def test_conversation
|
254
539
|
{
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
540
|
+
'type' => 'conversation',
|
541
|
+
'id' => '147',
|
542
|
+
'created_at' => 1_400_850_973,
|
543
|
+
'updated_at' => 1_400_857_494,
|
544
|
+
'conversation_message' => {
|
545
|
+
'type' => 'conversation_message',
|
546
|
+
'subject' => '',
|
547
|
+
'body' => "<p>Hi Alice,</p>\n\n<p>We noticed you using our Product, do you have any questions?</p> \n<p>- Jane</p>",
|
548
|
+
'author' => {
|
549
|
+
'type' => 'admin',
|
550
|
+
'id' => '25'
|
266
551
|
},
|
267
|
-
|
552
|
+
'attachments' => [
|
268
553
|
{
|
269
|
-
|
270
|
-
|
554
|
+
'name' => 'signature',
|
555
|
+
'url' => 'http =>//someurl.com/signature.jpg'
|
271
556
|
}
|
272
557
|
]
|
273
558
|
},
|
274
|
-
|
275
|
-
|
276
|
-
|
559
|
+
'user' => {
|
560
|
+
'type' => 'user',
|
561
|
+
'id' => '536e564f316c83104c000020'
|
277
562
|
},
|
278
|
-
|
279
|
-
|
280
|
-
|
563
|
+
'assignee' => {
|
564
|
+
'type' => 'admin',
|
565
|
+
'id' => '25'
|
281
566
|
},
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
567
|
+
'open' => true,
|
568
|
+
'read' => true,
|
569
|
+
'conversation_parts' => {
|
570
|
+
'type' => 'conversation_part.list',
|
571
|
+
'conversation_parts' => [
|
287
572
|
]
|
288
573
|
}
|
289
574
|
}
|
290
575
|
end
|
291
576
|
|
577
|
+
def test_conversation_list
|
578
|
+
{
|
579
|
+
'type' => 'conversation.list',
|
580
|
+
'pages' => {
|
581
|
+
'type' => 'pages',
|
582
|
+
'page' => 1,
|
583
|
+
'per_page' => 20,
|
584
|
+
'total_pages' => 1
|
585
|
+
},
|
586
|
+
'conversations' => [
|
587
|
+
{
|
588
|
+
'type' => 'conversation',
|
589
|
+
'id' => '147',
|
590
|
+
'created_at' => 1_400_850_973,
|
591
|
+
'updated_at' => 1_400_857_494,
|
592
|
+
'conversation_message' => {
|
593
|
+
'type' => 'conversation_message',
|
594
|
+
'subject' => '',
|
595
|
+
'body' => "<p>Hi Alice,</p>\n\n<p>We noticed you using our Product, do you have any questions?</p> \n<p>- Jane</p>",
|
596
|
+
'author' => {
|
597
|
+
'type' => 'admin',
|
598
|
+
'id' => '25'
|
599
|
+
},
|
600
|
+
'attachments' => [
|
601
|
+
{
|
602
|
+
'name' => 'signature',
|
603
|
+
'url' => 'http =>//someurl.com/signature.jpg'
|
604
|
+
}
|
605
|
+
]
|
606
|
+
},
|
607
|
+
'user' => {
|
608
|
+
'type' => 'user',
|
609
|
+
'id' => '536e564f316c83104c000020'
|
610
|
+
},
|
611
|
+
'assignee' => {
|
612
|
+
'type' => 'admin',
|
613
|
+
'id' => '25'
|
614
|
+
},
|
615
|
+
'open' => true,
|
616
|
+
'read' => true,
|
617
|
+
'conversation_parts' => {
|
618
|
+
'type' => 'conversation_part.list',
|
619
|
+
'conversation_parts' => [
|
620
|
+
]
|
621
|
+
}
|
622
|
+
}
|
623
|
+
]
|
624
|
+
}
|
625
|
+
end
|
626
|
+
|
292
627
|
def segment
|
293
628
|
{
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
629
|
+
'type' => 'segment',
|
630
|
+
'id' => '5310d8e7598c9a0b24000002',
|
631
|
+
'name' => 'Active',
|
632
|
+
'created_at' => 1_393_613_031,
|
633
|
+
'updated_at' => 1_393_613_031
|
299
634
|
}
|
300
635
|
end
|
301
636
|
|
302
637
|
def segment_list
|
303
638
|
{
|
304
|
-
|
305
|
-
|
639
|
+
'type' => 'segment.list',
|
640
|
+
'segments' => [
|
306
641
|
{
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
642
|
+
'created_at' => 1_393_613_031,
|
643
|
+
'id' => '5310d8e7598c9a0b24000002',
|
644
|
+
'name' => 'Active',
|
645
|
+
'type' => 'segment',
|
646
|
+
'updated_at' => 1_393_613_031
|
312
647
|
},
|
313
648
|
{
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
649
|
+
'created_at' => 1_393_613_030,
|
650
|
+
'id' => '5310d8e6598c9a0b24000001',
|
651
|
+
'name' => 'New',
|
652
|
+
'type' => 'segment',
|
653
|
+
'updated_at' => 1_393_613_030
|
319
654
|
},
|
320
655
|
{
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
656
|
+
'created_at' => 1_393_613_031,
|
657
|
+
'id' => '5310d8e7598c9a0b24000003',
|
658
|
+
'name' => 'Slipping Away',
|
659
|
+
'type' => 'segment',
|
660
|
+
'updated_at' => 1_393_613_031
|
326
661
|
}
|
327
662
|
]
|
328
663
|
}
|
@@ -330,207 +665,247 @@ end
|
|
330
665
|
|
331
666
|
def test_tag
|
332
667
|
{
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
668
|
+
'id' => '4f73428b5e4dfc000b000112',
|
669
|
+
'name' => 'Test Tag',
|
670
|
+
'segment' => false,
|
671
|
+
'tagged_company_count' => 2
|
337
672
|
}
|
338
673
|
end
|
339
674
|
|
340
675
|
def test_user_notification
|
341
676
|
{
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
677
|
+
'type' => 'notification_event',
|
678
|
+
'id' => 'notif_123456-56465-546546',
|
679
|
+
'topic' => 'user.created',
|
680
|
+
'app_id' => 'aaaaaa',
|
681
|
+
'data' =>
|
682
|
+
{
|
683
|
+
'type' => 'notification_event_data',
|
684
|
+
'item' =>
|
685
|
+
{
|
686
|
+
'type' => 'user',
|
687
|
+
'id' => 'aaaaaaaaaaaaaaaaaaaaaaaa',
|
688
|
+
'user_id' => nil,
|
689
|
+
'email' => 'joe@example.com',
|
690
|
+
'name' => 'Joe Schmoe',
|
691
|
+
'avatar' =>
|
692
|
+
{
|
693
|
+
'type' => 'avatar',
|
694
|
+
'image_url' => nil
|
695
|
+
},
|
696
|
+
'app_id' => 'aaaaa',
|
697
|
+
'companies' =>
|
698
|
+
{
|
699
|
+
'type' => 'company.list',
|
700
|
+
'companies' => []
|
701
|
+
},
|
702
|
+
'location_data' =>
|
703
|
+
{
|
704
|
+
},
|
705
|
+
'last_request_at' => nil,
|
706
|
+
'created_at' => '1401970114',
|
707
|
+
'remote_created_at' => nil,
|
708
|
+
'updated_at' => '1401970114',
|
709
|
+
'session_count' => 0,
|
710
|
+
'social_profiles' =>
|
711
|
+
{
|
712
|
+
'type' => 'social_profile.list',
|
713
|
+
'social_profiles' => []
|
714
|
+
},
|
715
|
+
'unsubscribed_from_emails' => false,
|
716
|
+
'user_agent_data' => nil,
|
717
|
+
'tags' =>
|
718
|
+
{
|
719
|
+
'type' => 'tag.list',
|
720
|
+
'tags' => []
|
721
|
+
},
|
722
|
+
'segments' =>
|
723
|
+
{
|
724
|
+
'type' => 'segment.list',
|
725
|
+
'segments' => []
|
726
|
+
},
|
727
|
+
'custom_attributes' =>
|
728
|
+
{
|
729
|
+
}
|
730
|
+
}
|
731
|
+
},
|
732
|
+
'delivery_status' => nil,
|
733
|
+
'delivery_attempts' => 1,
|
734
|
+
'delivered_at' => 0,
|
735
|
+
'first_sent_at' => 1_410_188_629,
|
736
|
+
'created_at' => 1_410_188_628,
|
737
|
+
'links' => {},
|
738
|
+
'self' => nil
|
404
739
|
}
|
405
740
|
end
|
406
741
|
|
407
742
|
def test_conversation_notification
|
408
743
|
{
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
{
|
415
|
-
"type"=>"notification_event_data",
|
416
|
-
"item"=>
|
744
|
+
'type' => 'notification_event',
|
745
|
+
'id' => 'notif_123456-56465-546546',
|
746
|
+
'topic' => 'conversation.user.created',
|
747
|
+
'app_id' => 'aaaaa',
|
748
|
+
'data' =>
|
417
749
|
{
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
750
|
+
'type' => 'notification_event_data',
|
751
|
+
'item' =>
|
752
|
+
{
|
753
|
+
'type' => 'conversation',
|
754
|
+
'id' => '123456789',
|
755
|
+
'created_at' => '1410335293',
|
756
|
+
'updated_at' => '1410335293',
|
757
|
+
'user' =>
|
758
|
+
{
|
759
|
+
'type' => 'user',
|
760
|
+
'id' => '540f1de7112d3d1d51001637',
|
761
|
+
'name' => 'Kill Bill',
|
762
|
+
'email' => 'bill@bill.bill'
|
763
|
+
},
|
764
|
+
'assignee' =>
|
765
|
+
{
|
766
|
+
'type' => 'nobody_admin',
|
767
|
+
'id' => nil
|
768
|
+
},
|
769
|
+
'conversation_message' =>
|
770
|
+
{
|
771
|
+
'type' => 'conversation_message',
|
772
|
+
'id' => '321546',
|
773
|
+
'subject' => '',
|
774
|
+
'body' => '<p>An important message</p>',
|
775
|
+
'author' =>
|
776
|
+
{
|
777
|
+
'type' => 'user',
|
778
|
+
'id' => 'aaaaaaaaaaaaaaaaaaaaaa',
|
779
|
+
'name' => 'Kill Bill',
|
780
|
+
'email' => 'bill@bill.bill'
|
781
|
+
},
|
782
|
+
'attachments' => []
|
783
|
+
},
|
784
|
+
'conversation_parts' =>
|
785
|
+
{
|
786
|
+
'type' => 'conversation_part.list',
|
787
|
+
'conversation_parts' => []
|
788
|
+
},
|
789
|
+
'open' => nil,
|
790
|
+
'read' => true,
|
791
|
+
'links' =>
|
792
|
+
{
|
793
|
+
'conversation_web' =>
|
794
|
+
'https://app.intercom.io/a/apps/aaaaaa/inbox/all/conversations/123456789'
|
795
|
+
}
|
796
|
+
}
|
797
|
+
},
|
798
|
+
'delivery_status' => nil,
|
799
|
+
'delivery_attempts' => 1,
|
800
|
+
'delivered_at' => 0,
|
801
|
+
'first_sent_at' => 1_410_335_293,
|
802
|
+
'created_at' => 1_410_335_293,
|
803
|
+
'links' => {},
|
804
|
+
'self' => nil
|
467
805
|
}
|
468
806
|
end
|
469
807
|
|
470
808
|
def test_subscription
|
471
|
-
{
|
472
|
-
{
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
{
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
809
|
+
{ 'request' =>
|
810
|
+
{ 'type' => 'notification_subscription',
|
811
|
+
'id' => 'nsub_123456789',
|
812
|
+
'created_at' => 1_410_368_642,
|
813
|
+
'updated_at' => 1_410_368_642,
|
814
|
+
'service_type' => 'web',
|
815
|
+
'app_id' => '3qmk5gyg',
|
816
|
+
'url' =>
|
817
|
+
'http://example.com',
|
818
|
+
'self' =>
|
819
|
+
'https://api.intercom.io/subscriptions/nsub_123456789',
|
820
|
+
'topics' => ['user.created', 'conversation.user.replied', 'conversation.admin.replied'],
|
821
|
+
'active' => true,
|
822
|
+
'metadata' => {},
|
823
|
+
'hub_secret' => nil,
|
824
|
+
'mode' => 'point',
|
825
|
+
'links' =>
|
826
|
+
{ 'sent' =>
|
827
|
+
'https://api.intercom.io/subscriptions/nsub_123456789/sent',
|
828
|
+
'retry' =>
|
829
|
+
'https://api.intercom.io/subscriptions/nsub_123456789/retry',
|
830
|
+
'errors' =>
|
831
|
+
'https://api.intercom.io/subscriptions/nsub_123456789/errors' },
|
832
|
+
'notes' => [] } }
|
495
833
|
end
|
496
834
|
|
497
835
|
def test_app_count
|
498
836
|
{
|
499
|
-
|
500
|
-
|
501
|
-
|
837
|
+
'type' => 'count.hash',
|
838
|
+
'company' => {
|
839
|
+
'count' => 8
|
502
840
|
},
|
503
|
-
|
504
|
-
|
841
|
+
'segment' => {
|
842
|
+
'count' => 47
|
505
843
|
},
|
506
|
-
|
507
|
-
|
844
|
+
'tag' => {
|
845
|
+
'count' => 341
|
508
846
|
},
|
509
|
-
|
510
|
-
|
847
|
+
'user' => {
|
848
|
+
'count' => 12_239
|
511
849
|
}
|
512
850
|
}
|
513
851
|
end
|
514
852
|
|
853
|
+
def test_section
|
854
|
+
{
|
855
|
+
'id' => '18',
|
856
|
+
'workspace_id' => 'tx2p130c',
|
857
|
+
'name' => 'Section 1',
|
858
|
+
'url' => 'http://www.intercom.test/help/',
|
859
|
+
'order' => 0,
|
860
|
+
'created_at' => 1_589_801_953,
|
861
|
+
'updated_at' => 1_589_801_953,
|
862
|
+
'type' => 'section',
|
863
|
+
'parent_id' => 1
|
864
|
+
}
|
865
|
+
end
|
866
|
+
|
867
|
+
def test_section_list
|
868
|
+
{
|
869
|
+
'type' => 'list',
|
870
|
+
'total_count' => 1,
|
871
|
+
'pages' => {
|
872
|
+
'page' => 1,
|
873
|
+
'per_page' => 20,
|
874
|
+
'total_pages' => 1
|
875
|
+
},
|
876
|
+
'data' => [{
|
877
|
+
'id' => '18',
|
878
|
+
'workspace_id' => 'tx2p130c',
|
879
|
+
'name' => 'Section 1',
|
880
|
+
'url' => 'http://www.intercom.test/help/',
|
881
|
+
'order' => 0,
|
882
|
+
'created_at' => 1_589_801_953,
|
883
|
+
'updated_at' => 1_589_801_953,
|
884
|
+
'type' => 'section',
|
885
|
+
'parent_id' => 1
|
886
|
+
}]
|
887
|
+
}
|
888
|
+
end
|
889
|
+
|
515
890
|
def test_segment_count
|
516
891
|
{
|
517
|
-
|
518
|
-
|
519
|
-
|
892
|
+
'type' => 'count',
|
893
|
+
'user' => {
|
894
|
+
'segment' => [
|
520
895
|
{
|
521
|
-
|
896
|
+
'Active' => 1
|
522
897
|
},
|
523
898
|
{
|
524
|
-
|
899
|
+
'New' => 0
|
525
900
|
},
|
526
901
|
{
|
527
|
-
|
902
|
+
'VIP' => 0
|
528
903
|
},
|
529
904
|
{
|
530
|
-
|
905
|
+
'Slipping Away' => 0
|
531
906
|
},
|
532
907
|
{
|
533
|
-
|
908
|
+
'segment 1' => 1
|
534
909
|
}
|
535
910
|
]
|
536
911
|
}
|
@@ -539,50 +914,120 @@ end
|
|
539
914
|
|
540
915
|
def test_conversation_count
|
541
916
|
{
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
917
|
+
'type' => 'count',
|
918
|
+
'conversation' => {
|
919
|
+
'assigned' => 1,
|
920
|
+
'closed' => 15,
|
921
|
+
'open' => 1,
|
922
|
+
'unassigned' => 0
|
548
923
|
}
|
549
924
|
}
|
550
925
|
end
|
551
926
|
|
552
927
|
def test_event
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
}
|
928
|
+
{
|
929
|
+
'type' => 'event',
|
930
|
+
'event_name' => 'invited-friend',
|
931
|
+
'created_at' => 1_389_913_941,
|
932
|
+
'user_id' => '314159',
|
933
|
+
'metadata' => {
|
934
|
+
'type' => 'user',
|
935
|
+
'invitee_email' => 'pi@example.org',
|
936
|
+
'invite_code' => 'ADDAFRIEND'
|
563
937
|
}
|
938
|
+
}
|
564
939
|
end
|
565
940
|
|
566
941
|
def test_event_list
|
567
942
|
{
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
943
|
+
'type' => 'event.list',
|
944
|
+
'events' => [test_event],
|
945
|
+
'pages' => {
|
946
|
+
'next' => 'https://api.intercom.io/events?type=user&intercom_user_id=55a3b&before=144474756550'
|
572
947
|
}
|
573
948
|
}
|
574
949
|
end
|
575
950
|
|
951
|
+
def tomorrow
|
952
|
+
(DateTime.now.to_time + 1).to_i
|
953
|
+
end
|
954
|
+
|
955
|
+
def page_of_events(include_next_link = false)
|
956
|
+
{
|
957
|
+
'type' => 'event.list',
|
958
|
+
'events' => [test_event],
|
959
|
+
'pages' =>
|
960
|
+
{
|
961
|
+
'next' => (include_next_link ? 'https://api.intercom.io/events?type=user&intercom_user_id=55a3b&before=144474756550' : nil)
|
962
|
+
}
|
963
|
+
}
|
964
|
+
end
|
965
|
+
|
966
|
+
def test_data_attribute
|
967
|
+
{
|
968
|
+
'type' => 'data_attribute',
|
969
|
+
'model' => 'contact',
|
970
|
+
'name' => 'region_name',
|
971
|
+
'full_name' => 'location_data.region_name',
|
972
|
+
'label' => 'Region',
|
973
|
+
'description' => '',
|
974
|
+
'data_type' => 'string',
|
975
|
+
'api_writable' => false,
|
976
|
+
'ui_writable' => true,
|
977
|
+
'custom' => false,
|
978
|
+
'archived' => false
|
979
|
+
}
|
980
|
+
end
|
981
|
+
|
982
|
+
def test_data_attribute_list
|
983
|
+
{
|
984
|
+
'type' => 'data_attribute.list',
|
985
|
+
'data_attributes' => [
|
986
|
+
{
|
987
|
+
'type' => 'data_attribute',
|
988
|
+
'model' => 'customer',
|
989
|
+
'name' => 'paid_subscriber',
|
990
|
+
'full_name' => 'custom_attributes.paid_subscriber',
|
991
|
+
'label' => 'paid_subscriber',
|
992
|
+
'description' => '',
|
993
|
+
'data_type' => 'string',
|
994
|
+
'options' => %w[
|
995
|
+
pick_value_1
|
996
|
+
pick_value_2
|
997
|
+
],
|
998
|
+
'api_writable' => true,
|
999
|
+
'ui_writable' => true,
|
1000
|
+
'custom' => true,
|
1001
|
+
'archived' => false,
|
1002
|
+
'admin_id' => '1',
|
1003
|
+
'created_at' => 1_392_734_388,
|
1004
|
+
'updated_at' => 1_392_734_388
|
1005
|
+
},
|
1006
|
+
{
|
1007
|
+
'type' => 'data_attribute',
|
1008
|
+
'model' => 'customer',
|
1009
|
+
'name' => 'region_name',
|
1010
|
+
'full_name' => 'location_data.region_name',
|
1011
|
+
'label' => 'Region',
|
1012
|
+
'description' => '',
|
1013
|
+
'data_type' => 'string',
|
1014
|
+
'api_writable' => false,
|
1015
|
+
'ui_writable' => true,
|
1016
|
+
'custom' => false,
|
1017
|
+
'archived' => false
|
1018
|
+
}
|
1019
|
+
]
|
1020
|
+
}
|
1021
|
+
end
|
1022
|
+
|
576
1023
|
def error_on_modify_frozen
|
577
1024
|
RUBY_VERSION =~ /1.8/ ? TypeError : RuntimeError
|
578
1025
|
end
|
579
1026
|
|
580
1027
|
def capture_exception(&block)
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
return e
|
585
|
-
end
|
1028
|
+
block.call
|
1029
|
+
rescue StandardError => e
|
1030
|
+
e
|
586
1031
|
end
|
587
1032
|
|
588
1033
|
def unshuffleable_array(array)
|