intercom 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -0
- data/README.md +2 -2
- data/changes.txt +3 -0
- data/intercom.gemspec +1 -1
- data/lib/intercom/errors.rb +1 -1
- data/lib/intercom/utils.rb +14 -2
- data/lib/intercom/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/intercom/collection_proxy_spec.rb +6 -6
- data/spec/unit/intercom/event_spec.rb +2 -2
- data/spec/unit/intercom/user_spec.rb +7 -5
- metadata +29 -18
- checksums.yaml +0 -7
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -11,7 +11,7 @@ For generating Intercom javascript script tags for Rails, please see https://git
|
|
11
11
|
## Upgrading information
|
12
12
|
Version 2 of intercom-ruby is not backwards compatible with previous versions. Be sure to test this new version before deploying to production. One other change you will need to make as part of the upgrade is to set `Intercom.app_api_key` and not set `Intercom.api_key` (you can continue to use your existing API key).
|
13
13
|
|
14
|
-
|
14
|
+
This version of the gem is compatible with `Ruby 2.1`, `Ruby 2.0` & `Ruby 1.9.3`
|
15
15
|
|
16
16
|
## Installation
|
17
17
|
|
@@ -19,7 +19,7 @@ Additionally, the new version uses Ruby 2.
|
|
19
19
|
|
20
20
|
Using bundler:
|
21
21
|
|
22
|
-
gem 'intercom', "~> 2.
|
22
|
+
gem 'intercom', "~> 2.4.0"
|
23
23
|
|
24
24
|
## Basic Usage
|
25
25
|
|
data/changes.txt
CHANGED
data/intercom.gemspec
CHANGED
data/lib/intercom/errors.rb
CHANGED
@@ -3,7 +3,7 @@ module Intercom
|
|
3
3
|
# Base class exception from which all public Intercom exceptions will be derived
|
4
4
|
class IntercomError < StandardError
|
5
5
|
attr_reader :http_code, :application_error_code
|
6
|
-
def initialize(message, http_code
|
6
|
+
def initialize(message, http_code = nil, application_error_code = application_error_code)
|
7
7
|
@http_code = http_code
|
8
8
|
@application_error_code = application_error_code
|
9
9
|
super(message)
|
data/lib/intercom/utils.rb
CHANGED
@@ -10,6 +10,18 @@ module Intercom
|
|
10
10
|
"#{str}s"
|
11
11
|
end
|
12
12
|
|
13
|
+
# the constantize method that exists in rails to allow for ruby 1.9 to get namespaced constants
|
14
|
+
def constantize(camel_cased_word)
|
15
|
+
names = camel_cased_word.split('::')
|
16
|
+
names.shift if names.empty? || names.first.empty?
|
17
|
+
|
18
|
+
constant = Object
|
19
|
+
names.each do |name|
|
20
|
+
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
21
|
+
end
|
22
|
+
constant
|
23
|
+
end
|
24
|
+
|
13
25
|
def resource_class_to_singular_name(resource_class)
|
14
26
|
resource_class.to_s.split('::')[-1].downcase
|
15
27
|
end
|
@@ -22,14 +34,14 @@ module Intercom
|
|
22
34
|
class_name = Utils.singularize(resource_name.capitalize)
|
23
35
|
define_lightweight_class(class_name) unless Intercom.const_defined?(class_name, false)
|
24
36
|
namespaced_class_name = "Intercom::#{class_name}"
|
25
|
-
|
37
|
+
constantize namespaced_class_name
|
26
38
|
end
|
27
39
|
|
28
40
|
def constantize_singular_resource_name(resource_name)
|
29
41
|
class_name = resource_name.split('_').map(&:capitalize).join
|
30
42
|
define_lightweight_class(class_name) unless Intercom.const_defined?(class_name, false)
|
31
43
|
namespaced_class_name = "Intercom::#{class_name}"
|
32
|
-
|
44
|
+
constantize namespaced_class_name
|
33
45
|
end
|
34
46
|
|
35
47
|
def define_lightweight_class(class_name)
|
data/lib/intercom/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -3,32 +3,32 @@ require "spec_helper"
|
|
3
3
|
describe Intercom::CollectionProxy do
|
4
4
|
|
5
5
|
it "stops iterating if no next link" do
|
6
|
-
Intercom.expects(:get).with("/users", {}).returns(page_of_users(
|
6
|
+
Intercom.expects(:get).with("/users", {}).returns(page_of_users(false))
|
7
7
|
emails = []
|
8
8
|
Intercom::User.all.each { |user| emails << user.email }
|
9
9
|
emails.must_equal %W(user1@example.com user2@example.com user3@example.com)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "keeps iterating if next link" do
|
13
|
-
Intercom.expects(:get).with("/users", {}).returns(page_of_users(
|
14
|
-
Intercom.expects(:get).with('https://api.intercom.io/users?per_page=50&page=2', {}).returns(page_of_users(
|
13
|
+
Intercom.expects(:get).with("/users", {}).returns(page_of_users(true))
|
14
|
+
Intercom.expects(:get).with('https://api.intercom.io/users?per_page=50&page=2', {}).returns(page_of_users(false))
|
15
15
|
emails = []
|
16
16
|
Intercom::User.all.each { |user| emails << user.email }
|
17
17
|
end
|
18
18
|
|
19
19
|
it "supports indexed array access" do
|
20
|
-
Intercom.expects(:get).with("/users", {}).returns(page_of_users(
|
20
|
+
Intercom.expects(:get).with("/users", {}).returns(page_of_users(false))
|
21
21
|
Intercom::User.all[0].email.must_equal 'user1@example.com'
|
22
22
|
end
|
23
23
|
|
24
24
|
it "supports map" do
|
25
|
-
Intercom.expects(:get).with("/users", {}).returns(page_of_users(
|
25
|
+
Intercom.expects(:get).with("/users", {}).returns(page_of_users(false))
|
26
26
|
emails = Intercom::User.all.map { |user| user.email }
|
27
27
|
emails.must_equal %W(user1@example.com user2@example.com user3@example.com)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "supports querying" do
|
31
|
-
Intercom.expects(:get).with("/users", {:tag_name => 'Taggart J'}).returns(page_of_users(
|
31
|
+
Intercom.expects(:get).with("/users", {:tag_name => 'Taggart J'}).returns(page_of_users(false))
|
32
32
|
Intercom::User.find_all(:tag_name => 'Taggart J').map(&:email).must_equal %W(user1@example.com user2@example.com user3@example.com)
|
33
33
|
end
|
34
34
|
end
|
@@ -2,8 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "Intercom::Event" do
|
4
4
|
|
5
|
-
let
|
6
|
-
let
|
5
|
+
let(:user) {Intercom::User.new("email" => "jim@example.com", :user_id => "12345", :created_at => Time.now, :name => "Jim Bob")}
|
6
|
+
let(:created_time) {Time.now - 300}
|
7
7
|
|
8
8
|
it "creates an event with metadata" do
|
9
9
|
Intercom.expects(:post).with('/events', {'event_name' => 'Eventful 1', 'created_at' => created_time.to_i, 'email' => 'joe@example.com', 'metadata' => {'invitee_email' => 'pi@example.org', :invite_code => 'ADDAFRIEND', 'found_date' => 12909364407}}).returns(:status => 202)
|
@@ -99,12 +99,13 @@ describe "Intercom::User" do
|
|
99
99
|
|
100
100
|
it "rejects nested data structures in custom_attributes" do
|
101
101
|
user = Intercom::User.new()
|
102
|
-
|
103
|
-
proc { user.custom_attributes["thing"] =
|
104
|
-
proc { user.custom_attributes = {1 =>
|
102
|
+
|
103
|
+
proc { user.custom_attributes["thing"] = [1] }.must_raise(ArgumentError)
|
104
|
+
proc { user.custom_attributes["thing"] = {1 => 2} }.must_raise(ArgumentError)
|
105
|
+
proc { user.custom_attributes["thing"] = {1 => {2 => 3}} }.must_raise(ArgumentError)
|
105
106
|
|
106
107
|
user = Intercom::User.from_api(test_user)
|
107
|
-
proc { user.custom_attributes["thing"] = [1] }.must_raise
|
108
|
+
proc { user.custom_attributes["thing"] = [1] }.must_raise(ArgumentError)
|
108
109
|
end
|
109
110
|
|
110
111
|
describe "incrementing custom_attributes fields" do
|
@@ -199,7 +200,8 @@ describe "Intercom::User" do
|
|
199
200
|
it "sets/gets rw keys" do
|
200
201
|
params = {"email" => "me@example.com", :user_id => "abc123", "name" => "Bob Smith", "last_seen_ip" => "1.2.3.4", "last_seen_user_agent" => "ie6", "created_at" => Time.now}
|
201
202
|
user = Intercom::User.new(params)
|
202
|
-
|
203
|
+
custom_attributes = (params.keys + ['custom_attributes']).map(&:to_s).sort
|
204
|
+
user.to_hash.keys.sort.must_equal custom_attributes
|
203
205
|
params.keys.each do |key|
|
204
206
|
user.send(key).to_s.must_equal params[key].to_s
|
205
207
|
end
|
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intercom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Ben McRedmond
|
@@ -15,53 +16,60 @@ authors:
|
|
15
16
|
autorequire:
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
|
-
date: 2014-10-
|
19
|
+
date: 2014-10-28 00:00:00.000000000 Z
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: minitest
|
22
23
|
requirement: !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
23
25
|
requirements:
|
24
|
-
- - '>='
|
26
|
+
- - ! '>='
|
25
27
|
- !ruby/object:Gem::Version
|
26
28
|
version: '0'
|
27
29
|
type: :development
|
28
30
|
prerelease: false
|
29
31
|
version_requirements: !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
30
33
|
requirements:
|
31
|
-
- - '>='
|
34
|
+
- - ! '>='
|
32
35
|
- !ruby/object:Gem::Version
|
33
36
|
version: '0'
|
34
37
|
- !ruby/object:Gem::Dependency
|
35
38
|
name: rake
|
36
39
|
requirement: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
37
41
|
requirements:
|
38
|
-
- - '>='
|
42
|
+
- - ! '>='
|
39
43
|
- !ruby/object:Gem::Version
|
40
44
|
version: '0'
|
41
45
|
type: :development
|
42
46
|
prerelease: false
|
43
47
|
version_requirements: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
44
49
|
requirements:
|
45
|
-
- - '>='
|
50
|
+
- - ! '>='
|
46
51
|
- !ruby/object:Gem::Version
|
47
52
|
version: '0'
|
48
53
|
- !ruby/object:Gem::Dependency
|
49
54
|
name: mocha
|
50
55
|
requirement: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
51
57
|
requirements:
|
52
|
-
- - '>='
|
58
|
+
- - ! '>='
|
53
59
|
- !ruby/object:Gem::Version
|
54
60
|
version: '0'
|
55
61
|
type: :development
|
56
62
|
prerelease: false
|
57
63
|
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
58
65
|
requirements:
|
59
|
-
- - '>='
|
66
|
+
- - ! '>='
|
60
67
|
- !ruby/object:Gem::Version
|
61
68
|
version: '0'
|
62
69
|
- !ruby/object:Gem::Dependency
|
63
70
|
name: fakeweb
|
64
71
|
requirement: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
65
73
|
requirements:
|
66
74
|
- - ~>
|
67
75
|
- !ruby/object:Gem::Version
|
@@ -69,6 +77,7 @@ dependencies:
|
|
69
77
|
type: :development
|
70
78
|
prerelease: false
|
71
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
72
81
|
requirements:
|
73
82
|
- - ~>
|
74
83
|
- !ruby/object:Gem::Version
|
@@ -76,18 +85,20 @@ dependencies:
|
|
76
85
|
- !ruby/object:Gem::Dependency
|
77
86
|
name: json
|
78
87
|
requirement: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
79
89
|
requirements:
|
80
|
-
- - '>='
|
90
|
+
- - ! '>='
|
81
91
|
- !ruby/object:Gem::Version
|
82
92
|
version: '0'
|
83
93
|
type: :runtime
|
84
94
|
prerelease: false
|
85
95
|
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
86
97
|
requirements:
|
87
|
-
- - '>='
|
98
|
+
- - ! '>='
|
88
99
|
- !ruby/object:Gem::Version
|
89
100
|
version: '0'
|
90
|
-
description: 'Intercom (https://www.intercom.io) is a customer relationship management
|
101
|
+
description: ! 'Intercom (https://www.intercom.io) is a customer relationship management
|
91
102
|
and messaging tool for web app owners. This library wraps the api provided by Intercom.
|
92
103
|
See http://docs.intercom.io/api for more details. '
|
93
104
|
email:
|
@@ -171,26 +182,27 @@ files:
|
|
171
182
|
homepage: https://www.intercom.io
|
172
183
|
licenses:
|
173
184
|
- MIT
|
174
|
-
metadata: {}
|
175
185
|
post_install_message:
|
176
186
|
rdoc_options: []
|
177
187
|
require_paths:
|
178
188
|
- lib
|
179
189
|
required_ruby_version: !ruby/object:Gem::Requirement
|
190
|
+
none: false
|
180
191
|
requirements:
|
181
|
-
- -
|
192
|
+
- - ! '>='
|
182
193
|
- !ruby/object:Gem::Version
|
183
|
-
version:
|
194
|
+
version: 1.9.3
|
184
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
|
+
none: false
|
185
197
|
requirements:
|
186
|
-
- - '>='
|
198
|
+
- - ! '>='
|
187
199
|
- !ruby/object:Gem::Version
|
188
200
|
version: '0'
|
189
201
|
requirements: []
|
190
202
|
rubyforge_project: intercom
|
191
|
-
rubygems_version:
|
203
|
+
rubygems_version: 1.8.23
|
192
204
|
signing_key:
|
193
|
-
specification_version:
|
205
|
+
specification_version: 3
|
194
206
|
summary: Ruby bindings for the Intercom API
|
195
207
|
test_files:
|
196
208
|
- spec/spec_helper.rb
|
@@ -208,4 +220,3 @@ test_files:
|
|
208
220
|
- spec/unit/intercom/traits/api_resource_spec.rb
|
209
221
|
- spec/unit/intercom/user_spec.rb
|
210
222
|
- spec/unit/intercom_spec.rb
|
211
|
-
has_rdoc:
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 513076550f366c50ddd55f25cf420c9e28ed4a67
|
4
|
-
data.tar.gz: fe6b1eb608e712aa9094035dc14b73e3c7005315
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 0a3d1a25d2f82c0e88b51c84172b966eeb35d3866a3ba66e5f197522c6e79710baf155166813514f17df91a14fda47e34f479d4632b94191d01b083684343a70
|
7
|
-
data.tar.gz: d90da12671da821d98af3c53009a64adb3425af83a407a428983bb926610c85b64f25171c620682b37271666d81e23562d234db518dcaa29c4bd8608db0705a2
|