intercom 3.0.0b1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +14 -3
- data/lib/intercom.rb +2 -0
- data/lib/intercom/client.rb +4 -0
- data/lib/intercom/count.rb +7 -0
- data/lib/intercom/service/count.rb +22 -0
- data/lib/intercom/version.rb +1 -1
- data/spec/spec_helper.rb +43 -0
- data/spec/unit/intercom/count_spec.rb +17 -0
- metadata +8 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bf276d9bcb6ec4c0a10de9e8f8ed2b665b37e88f
|
|
4
|
+
data.tar.gz: a72b07089606ba2f439acf3de33b702795669c1c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9fa345d1fb399d0b1c96da4e135cb751bc3138d2dd9e306541e9f606939d61aaafb259640a205f2ea7c16fa95725be3c19cb536d6f734b9afb7ccf891cb0ac98
|
|
7
|
+
data.tar.gz: 604e7edbfc96a8023591ced851914cc8c890845358b921b9db2a3db620150e61724a489418e666baaf200559ab4b1563a946b2ee7403e445dfed0229c0da0124
|
data/README.md
CHANGED
|
@@ -22,7 +22,7 @@ This version of the gem is compatible with `Ruby 2.1` and above.
|
|
|
22
22
|
|
|
23
23
|
Using bundler:
|
|
24
24
|
|
|
25
|
-
gem 'intercom', "~> 3.0.
|
|
25
|
+
gem 'intercom', "~> 3.0.0"
|
|
26
26
|
|
|
27
27
|
## Basic Usage
|
|
28
28
|
|
|
@@ -32,7 +32,7 @@ Using bundler:
|
|
|
32
32
|
intercom = Intercom::Client.new(app_id: 'my_app_id', api_key: 'my_api_key')
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
You can get your `app_id` from the URL when you're logged into Intercom (it's the alphanumeric just after `/apps/`) and your API key from the API keys integration settings page (under your app settings - integrations in Intercom).
|
|
35
|
+
You can get your `app_id` from the URL when you're logged into Intercom (it's the alphanumeric just after `/apps/`) and your API key from the API keys integration settings page (under your app settings - integrations in Intercom).
|
|
36
36
|
|
|
37
37
|
### Resources
|
|
38
38
|
|
|
@@ -41,6 +41,7 @@ Resources this API supports:
|
|
|
41
41
|
https://api.intercom.io/users
|
|
42
42
|
https://api.intercom.io/contacts
|
|
43
43
|
https://api.intercom.io/companies
|
|
44
|
+
https://api.intercom.io/counts
|
|
44
45
|
https://api.intercom.io/tags
|
|
45
46
|
https://api.intercom.io/notes
|
|
46
47
|
https://api.intercom.io/segments
|
|
@@ -111,7 +112,7 @@ intercom.companies.users(company.id)
|
|
|
111
112
|
# Tag users
|
|
112
113
|
tag = intercom.tags.tag(name: 'blue', users: [{email: "test1@example.com"}])
|
|
113
114
|
# Untag users
|
|
114
|
-
intercom.tags.
|
|
115
|
+
intercom.tags.untag(name: 'blue', users: [{user_id: "42ea2f1b93891f6a99000427"}])
|
|
115
116
|
# Iterate over all tags
|
|
116
117
|
intercom.tags.all.each {|tag| "#{tag.id} - #{tag.name}" }
|
|
117
118
|
intercom.tags.all.map {|tag| tag.name }
|
|
@@ -313,6 +314,16 @@ contacts = intercom.contacts.find_all(email: "some_contact@example.com")
|
|
|
313
314
|
intercom.contacts.convert(contact, user)
|
|
314
315
|
```
|
|
315
316
|
|
|
317
|
+
### Counts
|
|
318
|
+
|
|
319
|
+
```ruby
|
|
320
|
+
# App-wide counts
|
|
321
|
+
intercom.counts.for_app
|
|
322
|
+
|
|
323
|
+
# Users in segment counts
|
|
324
|
+
intercom.counts.for_type(type: 'user', count: 'segment')
|
|
325
|
+
```
|
|
326
|
+
|
|
316
327
|
### Subscriptions
|
|
317
328
|
|
|
318
329
|
Subscribe to events in Intercom to receive webhooks.
|
data/lib/intercom.rb
CHANGED
|
@@ -3,6 +3,7 @@ require 'intercom/service/admin'
|
|
|
3
3
|
require 'intercom/service/company'
|
|
4
4
|
require 'intercom/service/contact'
|
|
5
5
|
require 'intercom/service/conversation'
|
|
6
|
+
require 'intercom/service/count'
|
|
6
7
|
require 'intercom/service/event'
|
|
7
8
|
require 'intercom/service/message'
|
|
8
9
|
require 'intercom/service/note'
|
|
@@ -13,6 +14,7 @@ require 'intercom/service/user'
|
|
|
13
14
|
require 'intercom/options'
|
|
14
15
|
require 'intercom/client'
|
|
15
16
|
require "intercom/contact"
|
|
17
|
+
require "intercom/count"
|
|
16
18
|
require "intercom/user"
|
|
17
19
|
require "intercom/company"
|
|
18
20
|
require "intercom/note"
|
data/lib/intercom/client.rb
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'intercom/service/base_service'
|
|
2
|
+
require 'intercom/api_operations/find'
|
|
3
|
+
|
|
4
|
+
module Intercom
|
|
5
|
+
module Service
|
|
6
|
+
class Counts < BaseService
|
|
7
|
+
include ApiOperations::Find
|
|
8
|
+
|
|
9
|
+
def collection_class
|
|
10
|
+
Intercom::Count
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def for_app
|
|
14
|
+
find({})
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def for_type(type:, count: nil)
|
|
18
|
+
find(type: type, count: count)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/intercom/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
|
@@ -405,6 +405,49 @@ def test_subscription
|
|
|
405
405
|
"notes"=>[]}}
|
|
406
406
|
end
|
|
407
407
|
|
|
408
|
+
def test_app_count
|
|
409
|
+
{
|
|
410
|
+
"type" => "count.hash",
|
|
411
|
+
"company" => {
|
|
412
|
+
"count" => 8
|
|
413
|
+
},
|
|
414
|
+
"segment" => {
|
|
415
|
+
"count" => 47
|
|
416
|
+
},
|
|
417
|
+
"tag" => {
|
|
418
|
+
"count" => 341
|
|
419
|
+
},
|
|
420
|
+
"user" => {
|
|
421
|
+
"count" => 12239
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
def test_segment_count
|
|
427
|
+
{
|
|
428
|
+
"type" => "count",
|
|
429
|
+
"user" => {
|
|
430
|
+
"segment" => [
|
|
431
|
+
{
|
|
432
|
+
"Active" => 1
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
"New" => 0
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
"VIP" => 0
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"Slipping Away" => 0
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
"segment 1" => 1
|
|
445
|
+
}
|
|
446
|
+
]
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
end
|
|
450
|
+
|
|
408
451
|
def error_on_modify_frozen
|
|
409
452
|
RUBY_VERSION =~ /1.8/ ? TypeError : RuntimeError
|
|
410
453
|
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe "Intercom::Count" do
|
|
4
|
+
let (:client) { Intercom::Client.new(app_id: 'app_id', api_key: 'api_key') }
|
|
5
|
+
|
|
6
|
+
it 'should get app wide counts' do
|
|
7
|
+
client.expects(:get).with("/counts", {}).returns(test_app_count)
|
|
8
|
+
counts = client.counts.for_app
|
|
9
|
+
counts.tag['count'].must_equal(341)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'should get type counts' do
|
|
13
|
+
client.expects(:get).with("/counts", {type: 'user', count: 'segment'}).returns(test_segment_count)
|
|
14
|
+
counts = client.counts.for_type(type: 'user', count: 'segment')
|
|
15
|
+
counts.user['segment'][4]["segment 1"].must_equal(1)
|
|
16
|
+
end
|
|
17
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: intercom
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben McRedmond
|
|
@@ -15,7 +15,7 @@ authors:
|
|
|
15
15
|
autorequire:
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
|
-
date: 2015-06-
|
|
18
|
+
date: 2015-06-05 00:00:00.000000000 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: minitest
|
|
@@ -127,6 +127,7 @@ files:
|
|
|
127
127
|
- lib/intercom/company.rb
|
|
128
128
|
- lib/intercom/contact.rb
|
|
129
129
|
- lib/intercom/conversation.rb
|
|
130
|
+
- lib/intercom/count.rb
|
|
130
131
|
- lib/intercom/errors.rb
|
|
131
132
|
- lib/intercom/event.rb
|
|
132
133
|
- lib/intercom/extended_api_operations/segments.rb
|
|
@@ -146,6 +147,7 @@ files:
|
|
|
146
147
|
- lib/intercom/service/company.rb
|
|
147
148
|
- lib/intercom/service/contact.rb
|
|
148
149
|
- lib/intercom/service/conversation.rb
|
|
150
|
+
- lib/intercom/service/count.rb
|
|
149
151
|
- lib/intercom/service/event.rb
|
|
150
152
|
- lib/intercom/service/message.rb
|
|
151
153
|
- lib/intercom/service/note.rb
|
|
@@ -168,6 +170,7 @@ files:
|
|
|
168
170
|
- spec/unit/intercom/company_spec.rb
|
|
169
171
|
- spec/unit/intercom/contact_spec.rb
|
|
170
172
|
- spec/unit/intercom/conversation_spec.rb
|
|
173
|
+
- spec/unit/intercom/count_spec.rb
|
|
171
174
|
- spec/unit/intercom/event_spec.rb
|
|
172
175
|
- spec/unit/intercom/lib/flat_store_spec.rb
|
|
173
176
|
- spec/unit/intercom/message_spec.rb
|
|
@@ -194,9 +197,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
194
197
|
version: 2.1.0
|
|
195
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
199
|
requirements:
|
|
197
|
-
- - "
|
|
200
|
+
- - ">="
|
|
198
201
|
- !ruby/object:Gem::Version
|
|
199
|
-
version:
|
|
202
|
+
version: '0'
|
|
200
203
|
requirements: []
|
|
201
204
|
rubyforge_project: intercom
|
|
202
205
|
rubygems_version: 2.2.2
|
|
@@ -211,6 +214,7 @@ test_files:
|
|
|
211
214
|
- spec/unit/intercom/company_spec.rb
|
|
212
215
|
- spec/unit/intercom/contact_spec.rb
|
|
213
216
|
- spec/unit/intercom/conversation_spec.rb
|
|
217
|
+
- spec/unit/intercom/count_spec.rb
|
|
214
218
|
- spec/unit/intercom/event_spec.rb
|
|
215
219
|
- spec/unit/intercom/lib/flat_store_spec.rb
|
|
216
220
|
- spec/unit/intercom/message_spec.rb
|