intercom 3.9.5 → 4.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +406 -236
- data/Rakefile +1 -1
- data/changes.txt +32 -0
- data/lib/intercom/api_operations/archive.rb +2 -1
- data/lib/intercom/api_operations/delete.rb +16 -0
- 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/save.rb +6 -4
- data/lib/intercom/api_operations/scroll.rb +4 -5
- data/lib/intercom/api_operations/search.rb +3 -2
- data/lib/intercom/article.rb +7 -0
- data/lib/intercom/base_collection_proxy.rb +73 -0
- data/lib/intercom/client.rb +36 -25
- 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 +3 -0
- 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/dynamic_accessors.rb +9 -10
- data/lib/intercom/lib/typed_json_deserializer.rb +42 -37
- data/lib/intercom/note.rb +4 -0
- data/lib/intercom/request.rb +37 -33
- data/lib/intercom/scroll_collection_proxy.rb +38 -42
- data/lib/intercom/search_collection_proxy.rb +30 -65
- 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 +7 -0
- data/lib/intercom/service/collection.rb +24 -0
- data/lib/intercom/service/company.rb +2 -12
- data/lib/intercom/service/contact.rb +31 -10
- data/lib/intercom/service/conversation.rb +12 -3
- data/lib/intercom/service/data_attribute.rb +20 -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/subscription.rb +2 -2
- data/lib/intercom/service/tag.rb +9 -9
- data/lib/intercom/service/visitor.rb +17 -8
- data/lib/intercom/tag.rb +4 -0
- data/lib/intercom/traits/api_resource.rb +44 -18
- 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/lib/intercom.rb +33 -22
- data/spec/spec_helper.rb +843 -520
- 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 +47 -0
- data/spec/unit/intercom/client_collection_proxy_spec.rb +41 -41
- data/spec/unit/intercom/client_spec.rb +25 -26
- data/spec/unit/intercom/collection_spec.rb +32 -0
- data/spec/unit/intercom/company_spec.rb +18 -14
- data/spec/unit/intercom/contact_spec.rb +385 -33
- data/spec/unit/intercom/conversation_spec.rb +55 -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 +9 -11
- 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 +1 -1
- data/spec/unit/intercom/scroll_collection_proxy_spec.rb +40 -39
- data/spec/unit/intercom/search_collection_proxy_spec.rb +32 -28
- 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 +2 -2
- data/spec/unit/intercom/traits/api_resource_spec.rb +107 -52
- data/spec/unit/intercom/user_spec.rb +224 -226
- data/spec/unit/intercom/visitor_spec.rb +49 -0
- data/spec/unit/intercom_spec.rb +5 -3
- metadata +34 -8
- data/lib/intercom/customer.rb +0 -10
- data/lib/intercom/service/customer.rb +0 -14
- data/spec/unit/intercom/visitors_spec.rb +0 -61
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'intercom'
|
2
4
|
require 'minitest/autorun'
|
3
5
|
require 'mocha/setup'
|
@@ -6,132 +8,236 @@ require 'time'
|
|
6
8
|
require 'pry'
|
7
9
|
include WebMock::API
|
8
10
|
|
9
|
-
def
|
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
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
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
|
91
|
+
|
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
|
123
229
|
}
|
124
230
|
end
|
125
231
|
|
126
232
|
def test_admin_list
|
127
233
|
{
|
128
|
-
|
129
|
-
|
234
|
+
'type' => 'admin.list',
|
235
|
+
'admins' => [
|
130
236
|
{
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
237
|
+
'type' => 'admin',
|
238
|
+
'id' => '1234',
|
239
|
+
'name' => 'Hoban Washburne',
|
240
|
+
'email' => 'wash@serenity.io'
|
135
241
|
}
|
136
242
|
]
|
137
243
|
}
|
@@ -139,63 +245,88 @@ end
|
|
139
245
|
|
140
246
|
def test_admin
|
141
247
|
{
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
248
|
+
'type' => 'admin',
|
249
|
+
'id' => '1234',
|
250
|
+
'name' => 'Hoban Washburne',
|
251
|
+
'email' => 'wash@serenity.io'
|
146
252
|
}
|
147
253
|
end
|
148
254
|
|
149
255
|
def test_team_list
|
150
256
|
{
|
151
|
-
|
152
|
-
|
257
|
+
'type' => 'team.list',
|
258
|
+
'teams' => [
|
153
259
|
{
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
260
|
+
'type' => 'team',
|
261
|
+
'id' => '2744328',
|
262
|
+
'name' => 'the_a_team',
|
263
|
+
'admin_ids' => [646_303, 814_860]
|
158
264
|
},
|
159
265
|
{
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
}
|
266
|
+
'type' => 'team',
|
267
|
+
'id' => '814865',
|
268
|
+
'name' => 'BA_App',
|
269
|
+
'admin_ids' => [492_881, 1_195_856]
|
270
|
+
}
|
165
271
|
]
|
166
272
|
}
|
167
273
|
end
|
168
274
|
|
169
275
|
def test_team
|
170
276
|
{
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
277
|
+
'type' => 'team',
|
278
|
+
'id' => '2744328',
|
279
|
+
'name' => 'the_a_team',
|
280
|
+
'admin_ids' => [646_303, 814_860]
|
175
281
|
}
|
176
282
|
end
|
177
283
|
|
178
|
-
def test_company
|
284
|
+
def test_company(name = 'Blue Sun')
|
179
285
|
{
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
286
|
+
'type' => 'company',
|
287
|
+
'id' => '531ee472cce572a6ec000006',
|
288
|
+
'name' => name,
|
289
|
+
'plan' => {
|
290
|
+
'type' => 'plan',
|
291
|
+
'id' => '1',
|
292
|
+
'name' => 'Paid'
|
187
293
|
},
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
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
|
+
}
|
306
|
+
}
|
307
|
+
end
|
308
|
+
|
309
|
+
def test_company_dates(name = 'Blue Sun', created_at = 1_401_970_114, last_request_at = 1_401_970_113)
|
310
|
+
{
|
311
|
+
'type' => 'company',
|
312
|
+
'id' => '531ee472cce572a6ec000006',
|
313
|
+
'name' => name,
|
314
|
+
'plan' => {
|
315
|
+
'type' => 'plan',
|
316
|
+
'id' => '1',
|
317
|
+
'name' => 'Paid'
|
318
|
+
},
|
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
|
199
330
|
}
|
200
331
|
}
|
201
332
|
end
|
@@ -206,140 +337,238 @@ end
|
|
206
337
|
|
207
338
|
def test_message
|
208
339
|
{
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
},
|
235
|
-
"is_admin" => true
|
236
|
-
}
|
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'
|
237
365
|
},
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
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
|
+
]
|
249
380
|
}
|
250
381
|
end
|
251
382
|
|
252
|
-
def page_of_users(include_next_link= false)
|
383
|
+
def page_of_users(include_next_link = false)
|
253
384
|
{
|
254
|
-
|
255
|
-
|
385
|
+
'type' => 'user.list',
|
386
|
+
'pages' =>
|
256
387
|
{
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
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
|
262
393
|
},
|
263
|
-
|
264
|
-
|
394
|
+
'users' => [test_user('user1@example.com'), test_user('user2@example.com'), test_user('user3@example.com')],
|
395
|
+
'total_count' => 314
|
265
396
|
}
|
266
397
|
end
|
267
398
|
|
268
|
-
def
|
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)
|
269
498
|
{
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
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
|
281
510
|
}
|
282
511
|
end
|
283
512
|
|
284
|
-
def
|
513
|
+
def companies_scroll(include_companies = false)
|
285
514
|
{
|
286
|
-
|
287
|
-
|
288
|
-
|
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')] : [])
|
289
518
|
}
|
290
519
|
end
|
291
520
|
|
292
|
-
def
|
521
|
+
def companies_pagination(include_next_link:, per_page:, page:, total_pages:, total_count:, company_list:)
|
293
522
|
{
|
294
|
-
|
295
|
-
|
523
|
+
'type' => 'company.list',
|
524
|
+
'pages' =>
|
296
525
|
{
|
297
|
-
|
298
|
-
|
299
|
-
+ per_page.to_s +
|
300
|
-
|
301
|
-
|
302
|
-
|
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
|
303
532
|
},
|
304
|
-
|
305
|
-
|
533
|
+
'companies' => company_list,
|
534
|
+
'total_count' => total_count
|
306
535
|
}
|
307
536
|
end
|
308
537
|
|
309
538
|
def test_conversation
|
310
539
|
{
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
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'
|
322
551
|
},
|
323
|
-
|
552
|
+
'attachments' => [
|
324
553
|
{
|
325
|
-
|
326
|
-
|
554
|
+
'name' => 'signature',
|
555
|
+
'url' => 'http =>//someurl.com/signature.jpg'
|
327
556
|
}
|
328
557
|
]
|
329
558
|
},
|
330
|
-
|
331
|
-
|
332
|
-
|
559
|
+
'user' => {
|
560
|
+
'type' => 'user',
|
561
|
+
'id' => '536e564f316c83104c000020'
|
333
562
|
},
|
334
|
-
|
335
|
-
|
336
|
-
|
563
|
+
'assignee' => {
|
564
|
+
'type' => 'admin',
|
565
|
+
'id' => '25'
|
337
566
|
},
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
567
|
+
'open' => true,
|
568
|
+
'read' => true,
|
569
|
+
'conversation_parts' => {
|
570
|
+
'type' => 'conversation_part.list',
|
571
|
+
'conversation_parts' => [
|
343
572
|
]
|
344
573
|
}
|
345
574
|
}
|
@@ -347,88 +576,88 @@ end
|
|
347
576
|
|
348
577
|
def test_conversation_list
|
349
578
|
{
|
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
|
-
|
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
|
+
]
|
395
624
|
}
|
396
625
|
end
|
397
626
|
|
398
627
|
def segment
|
399
628
|
{
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
629
|
+
'type' => 'segment',
|
630
|
+
'id' => '5310d8e7598c9a0b24000002',
|
631
|
+
'name' => 'Active',
|
632
|
+
'created_at' => 1_393_613_031,
|
633
|
+
'updated_at' => 1_393_613_031
|
405
634
|
}
|
406
635
|
end
|
407
636
|
|
408
637
|
def segment_list
|
409
638
|
{
|
410
|
-
|
411
|
-
|
639
|
+
'type' => 'segment.list',
|
640
|
+
'segments' => [
|
412
641
|
{
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
642
|
+
'created_at' => 1_393_613_031,
|
643
|
+
'id' => '5310d8e7598c9a0b24000002',
|
644
|
+
'name' => 'Active',
|
645
|
+
'type' => 'segment',
|
646
|
+
'updated_at' => 1_393_613_031
|
418
647
|
},
|
419
648
|
{
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
649
|
+
'created_at' => 1_393_613_030,
|
650
|
+
'id' => '5310d8e6598c9a0b24000001',
|
651
|
+
'name' => 'New',
|
652
|
+
'type' => 'segment',
|
653
|
+
'updated_at' => 1_393_613_030
|
425
654
|
},
|
426
655
|
{
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
656
|
+
'created_at' => 1_393_613_031,
|
657
|
+
'id' => '5310d8e7598c9a0b24000003',
|
658
|
+
'name' => 'Slipping Away',
|
659
|
+
'type' => 'segment',
|
660
|
+
'updated_at' => 1_393_613_031
|
432
661
|
}
|
433
662
|
]
|
434
663
|
}
|
@@ -436,207 +665,247 @@ end
|
|
436
665
|
|
437
666
|
def test_tag
|
438
667
|
{
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
668
|
+
'id' => '4f73428b5e4dfc000b000112',
|
669
|
+
'name' => 'Test Tag',
|
670
|
+
'segment' => false,
|
671
|
+
'tagged_company_count' => 2
|
443
672
|
}
|
444
673
|
end
|
445
674
|
|
446
675
|
def test_user_notification
|
447
676
|
{
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
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
|
510
739
|
}
|
511
740
|
end
|
512
741
|
|
513
742
|
def test_conversation_notification
|
514
743
|
{
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
{
|
521
|
-
"type"=>"notification_event_data",
|
522
|
-
"item"=>
|
744
|
+
'type' => 'notification_event',
|
745
|
+
'id' => 'notif_123456-56465-546546',
|
746
|
+
'topic' => 'conversation.user.created',
|
747
|
+
'app_id' => 'aaaaa',
|
748
|
+
'data' =>
|
523
749
|
{
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
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
|
573
805
|
}
|
574
806
|
end
|
575
807
|
|
576
808
|
def test_subscription
|
577
|
-
{
|
578
|
-
{
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
{
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
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' => [] } }
|
601
833
|
end
|
602
834
|
|
603
835
|
def test_app_count
|
604
836
|
{
|
605
|
-
|
606
|
-
|
607
|
-
|
837
|
+
'type' => 'count.hash',
|
838
|
+
'company' => {
|
839
|
+
'count' => 8
|
608
840
|
},
|
609
|
-
|
610
|
-
|
841
|
+
'segment' => {
|
842
|
+
'count' => 47
|
611
843
|
},
|
612
|
-
|
613
|
-
|
844
|
+
'tag' => {
|
845
|
+
'count' => 341
|
614
846
|
},
|
615
|
-
|
616
|
-
|
847
|
+
'user' => {
|
848
|
+
'count' => 12_239
|
617
849
|
}
|
618
850
|
}
|
619
851
|
end
|
620
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
|
+
|
621
890
|
def test_segment_count
|
622
891
|
{
|
623
|
-
|
624
|
-
|
625
|
-
|
892
|
+
'type' => 'count',
|
893
|
+
'user' => {
|
894
|
+
'segment' => [
|
626
895
|
{
|
627
|
-
|
896
|
+
'Active' => 1
|
628
897
|
},
|
629
898
|
{
|
630
|
-
|
899
|
+
'New' => 0
|
631
900
|
},
|
632
901
|
{
|
633
|
-
|
902
|
+
'VIP' => 0
|
634
903
|
},
|
635
904
|
{
|
636
|
-
|
905
|
+
'Slipping Away' => 0
|
637
906
|
},
|
638
907
|
{
|
639
|
-
|
908
|
+
'segment 1' => 1
|
640
909
|
}
|
641
910
|
]
|
642
911
|
}
|
@@ -645,36 +914,36 @@ end
|
|
645
914
|
|
646
915
|
def test_conversation_count
|
647
916
|
{
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
917
|
+
'type' => 'count',
|
918
|
+
'conversation' => {
|
919
|
+
'assigned' => 1,
|
920
|
+
'closed' => 15,
|
921
|
+
'open' => 1,
|
922
|
+
'unassigned' => 0
|
654
923
|
}
|
655
924
|
}
|
656
925
|
end
|
657
926
|
|
658
927
|
def test_event
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
}
|
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'
|
669
937
|
}
|
938
|
+
}
|
670
939
|
end
|
671
940
|
|
672
941
|
def test_event_list
|
673
942
|
{
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
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'
|
678
947
|
}
|
679
948
|
}
|
680
949
|
end
|
@@ -683,28 +952,82 @@ def tomorrow
|
|
683
952
|
(DateTime.now.to_time + 1).to_i
|
684
953
|
end
|
685
954
|
|
686
|
-
def page_of_events(include_next_link=false)
|
955
|
+
def page_of_events(include_next_link = false)
|
687
956
|
{
|
688
|
-
|
689
|
-
|
690
|
-
|
957
|
+
'type' => 'event.list',
|
958
|
+
'events' => [test_event],
|
959
|
+
'pages' =>
|
691
960
|
{
|
692
|
-
|
961
|
+
'next' => (include_next_link ? 'https://api.intercom.io/events?type=user&intercom_user_id=55a3b&before=144474756550' : nil)
|
693
962
|
}
|
694
963
|
}
|
695
964
|
end
|
696
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
|
697
1022
|
|
698
1023
|
def error_on_modify_frozen
|
699
1024
|
RUBY_VERSION =~ /1.8/ ? TypeError : RuntimeError
|
700
1025
|
end
|
701
1026
|
|
702
1027
|
def capture_exception(&block)
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
return e
|
707
|
-
end
|
1028
|
+
block.call
|
1029
|
+
rescue StandardError => e
|
1030
|
+
e
|
708
1031
|
end
|
709
1032
|
|
710
1033
|
def unshuffleable_array(array)
|