intercom 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b1cf597e7167e94a21fc5c87f30a68971539d723
4
+ data.tar.gz: 2f7292ed806ece40ea6e7f681cd66b3b2b6b15c2
5
+ SHA512:
6
+ metadata.gz: 963e7576902470b933f63a9c5fb330366ef3addc5336155b9f1ad7be627a91dee57317f52b754944a061b504fdfbea3eef4081131570dfc43dde66ee992262c1
7
+ data.tar.gz: 9567e21985af78ea96cd4a85ccb7c4028af60125f7e04775bf79de53d857a5136ded318bd409fdb5d2ba4fed5a210585189c56a64974f68240652e723ea484df
data/changes.txt CHANGED
@@ -1,3 +1,6 @@
1
+ 0.1.13
2
+ - Add license to gemspec
3
+
1
4
  0.1.12
2
5
  - Fix the admin avatar attributes for MessageAuthor
3
6
  - Add ability to send increments
data/intercom.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.homepage = "https://www.intercom.io"
12
12
  spec.summary = %q{Ruby bindings for the Intercom API}
13
13
  spec.description = %Q{Intercom (https://www.intercom.io) is a customer relationship management and messaging tool for web app owners. This library wraps the api provided by Intercom. See http://docs.intercom.io/api for more details. }
14
-
14
+ spec.license = "MIT"
15
15
  spec.rubyforge_project = "intercom"
16
16
 
17
17
  spec.files = `git ls-files`.split("\n")
@@ -144,7 +144,7 @@ module Intercom
144
144
 
145
145
  # each {Message} in a {MessageThread} has a {MessageAuthor}
146
146
  #
147
- # Admin authors have a name, and an avatar_path_50. Non-admin authors have a name, user_id and email.
147
+ # Admin authors have a name, avatar_path_25, avatar_path_50, and avatar_path_128. Non-admin authors have a name, user_id and email.
148
148
  class MessageAuthor
149
149
  # Used to create a {MessageAuthor} from part of the response from the API
150
150
  def initialize(params)
@@ -166,9 +166,19 @@ module Intercom
166
166
  @attributes['user_id']
167
167
  end
168
168
 
169
+ # @return [String] url of 25x25 avatar of the admin who posted this message (only available when {#admin?} is true)
170
+ def avatar_path_25
171
+ self.admin? ? @attributes['avatar']['square_25'] : nil
172
+ end
173
+
169
174
  # @return [String] url of 50x50 avatar of the admin who posted this message (only available when {#admin?} is true)
170
175
  def avatar_path_50
171
- @attributes['avatar_path_50']
176
+ self.admin? ? @attributes['avatar']['square_50'] : nil
177
+ end
178
+
179
+ # @return [String] url of 128x128 avatar of the admin who posted this message (only available when {#admin?} is true)
180
+ def avatar_path_128
181
+ self.admin? ? @attributes['avatar']['square_128'] : nil
172
182
  end
173
183
 
174
184
  # @return [String] real name of the Admin/User, when available.
data/lib/intercom/user.rb CHANGED
@@ -129,6 +129,13 @@ module Intercom
129
129
  self.update_from_api_response(response)
130
130
  end
131
131
 
132
+ # Increment a custom data value on a user
133
+ # @return [User]
134
+ def increment(key, value=1)
135
+ increments[key] ||= 0
136
+ increments[key] += value
137
+ end
138
+
132
139
  # @return [String] the {User}'s name
133
140
  def name
134
141
  @attributes["name"]
@@ -330,5 +337,13 @@ module Intercom
330
337
  def location_data=(hash) #:nodoc:
331
338
  @location_data = hash.freeze
332
339
  end
340
+
341
+ def increments
342
+ @attributes["increments"] ||= {}
343
+ end
344
+
345
+ def increments=(hash)
346
+ @attributes["increments"] = hash
347
+ end
333
348
  end
334
349
  end
@@ -1,3 +1,3 @@
1
1
  module Intercom #:nodoc:
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.13"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -54,7 +54,11 @@ def test_message
54
54
  "rendered_body" => "<p>Not much, you?</p>\n",
55
55
  "from" => {
56
56
  "name" => "Super Duper Admin",
57
- "avatar_path_50" => "https//s3.amazonaws.com/intercom-prod/app/public/system/avatars/1454/medium/intercom-ben-avatar.jpg?1326725052",
57
+ "avatar" => {
58
+ "square_25" => "https://static.intercomcdn.com/avatars/13347/square_25/Ruairi_Profile.png?1375368166",
59
+ "square_50" => "https://static.intercomcdn.com/avatars/13347/square_50/Ruairi_Profile.png?1375368166",
60
+ "square_128" => "https://static.intercomcdn.com/avatars/13347/square_128/Ruairi_Profile.png?1375368166"
61
+ },
58
62
  "is_admin" => true
59
63
  }
60
64
  },
@@ -68,7 +68,7 @@ describe "/v1/messages_threads" do
68
68
  message_thread.messages[1].from.name.must_equal from_1['name']
69
69
  message_thread.messages[1].from.admin?.must_equal from_1['is_admin']
70
70
  message_thread.messages[1].from.user_id.must_equal from_1['user_id']
71
- message_thread.messages[1].from.avatar_path_50.must_equal from_1['avatar_path_50']
71
+ message_thread.messages[1].from.avatar_path_50.must_equal from_1['avatar']['square_50']
72
72
  end
73
73
  end
74
74
  end
@@ -107,6 +107,51 @@ describe "Intercom::User" do
107
107
  proc { user.custom_data["thing"] = [1] }.must_raise ArgumentError
108
108
  end
109
109
 
110
+ describe "incrementing custom_data fields" do
111
+ before :each do
112
+ @now = Time.now
113
+ @user = Intercom::User.new("email" => "jo@example.com", :user_id => "i-1224242", :custom_data => {"mad" => 123, "another" => 432, "other" => @now.to_i, :thing => "yay"})
114
+ end
115
+
116
+ it "increments up by 1 with no args" do
117
+ @user.increment("mad")
118
+ @user.to_hash["increments"].must_equal "mad" => 1
119
+ end
120
+
121
+ it "increments up by given value" do
122
+ @user.increment("mad", 4)
123
+ @user.to_hash["increments"].must_equal "mad" => 4
124
+ end
125
+
126
+ it "increments down by given value" do
127
+ @user.increment("mad", -1)
128
+ @user.to_hash["increments"].must_equal "mad" => -1
129
+ end
130
+
131
+ it "doesn't allow direct access to increments hash" do
132
+ proc { @user.increments["mad"] = 1 }.must_raise NoMethodError
133
+ proc { @user.increments }.must_raise NoMethodError
134
+ end
135
+
136
+ it "can update the increments hash without losing previous changes" do
137
+ @user.increment("mad")
138
+ @user.to_hash["increments"].must_equal "mad" => 1
139
+ @user.increment("another", -2)
140
+ @user.to_hash["increments"].must_equal "mad" => 1, "another" => -2
141
+ end
142
+
143
+ it "can increment new custom data fields" do
144
+ @user.increment("new_field", 3)
145
+ @user.to_hash["increments"].must_equal "new_field" => 3
146
+ end
147
+
148
+ it "can call increment on the same key twice and increment by 2" do
149
+ @user.increment("mad")
150
+ @user.increment("mad")
151
+ @user.to_hash["increments"].must_equal "mad" => 2
152
+ end
153
+ end
154
+
110
155
  it "fetches a user" do
111
156
  Intercom.expects(:get).with("/v1/users", {"email" => "bo@example.com"}).returns(test_user)
112
157
  user = Intercom::User.find("email" => "bo@example.com")
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intercom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
5
- prerelease:
4
+ version: 0.1.13
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ben McRedmond
@@ -13,57 +12,51 @@ authors:
13
12
  autorequire:
14
13
  bindir: bin
15
14
  cert_chain: []
16
- date: 2013-08-28 00:00:00.000000000 Z
15
+ date: 2013-08-29 00:00:00.000000000 Z
17
16
  dependencies:
18
17
  - !ruby/object:Gem::Dependency
19
18
  name: minitest
20
19
  requirement: !ruby/object:Gem::Requirement
21
- none: false
22
20
  requirements:
23
- - - ! '>='
21
+ - - '>='
24
22
  - !ruby/object:Gem::Version
25
23
  version: '0'
26
24
  type: :development
27
25
  prerelease: false
28
26
  version_requirements: !ruby/object:Gem::Requirement
29
- none: false
30
27
  requirements:
31
- - - ! '>='
28
+ - - '>='
32
29
  - !ruby/object:Gem::Version
33
30
  version: '0'
34
31
  - !ruby/object:Gem::Dependency
35
32
  name: rake
36
33
  requirement: !ruby/object:Gem::Requirement
37
- none: false
38
34
  requirements:
39
- - - ! '>='
35
+ - - '>='
40
36
  - !ruby/object:Gem::Version
41
37
  version: '0'
42
38
  type: :development
43
39
  prerelease: false
44
40
  version_requirements: !ruby/object:Gem::Requirement
45
- none: false
46
41
  requirements:
47
- - - ! '>='
42
+ - - '>='
48
43
  - !ruby/object:Gem::Version
49
44
  version: '0'
50
45
  - !ruby/object:Gem::Dependency
51
46
  name: mocha
52
47
  requirement: !ruby/object:Gem::Requirement
53
- none: false
54
48
  requirements:
55
- - - ! '>='
49
+ - - '>='
56
50
  - !ruby/object:Gem::Version
57
51
  version: '0'
58
52
  type: :development
59
53
  prerelease: false
60
54
  version_requirements: !ruby/object:Gem::Requirement
61
- none: false
62
55
  requirements:
63
- - - ! '>='
56
+ - - '>='
64
57
  - !ruby/object:Gem::Version
65
58
  version: '0'
66
- description: ! 'Intercom (https://www.intercom.io) is a customer relationship management
59
+ description: 'Intercom (https://www.intercom.io) is a customer relationship management
67
60
  and messaging tool for web app owners. This library wraps the api provided by Intercom.
68
61
  See http://docs.intercom.io/api for more details. '
69
62
  email:
@@ -112,28 +105,28 @@ files:
112
105
  - spec/unit/intercom/user_spec.rb
113
106
  - spec/unit/intercom_spec.rb
114
107
  homepage: https://www.intercom.io
115
- licenses: []
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
116
111
  post_install_message:
117
112
  rdoc_options: []
118
113
  require_paths:
119
114
  - lib
120
115
  required_ruby_version: !ruby/object:Gem::Requirement
121
- none: false
122
116
  requirements:
123
- - - ! '>='
117
+ - - '>='
124
118
  - !ruby/object:Gem::Version
125
119
  version: '0'
126
120
  required_rubygems_version: !ruby/object:Gem::Requirement
127
- none: false
128
121
  requirements:
129
- - - ! '>='
122
+ - - '>='
130
123
  - !ruby/object:Gem::Version
131
124
  version: '0'
132
125
  requirements: []
133
126
  rubyforge_project: intercom
134
- rubygems_version: 1.8.23
127
+ rubygems_version: 2.0.3
135
128
  signing_key:
136
- specification_version: 3
129
+ specification_version: 4
137
130
  summary: Ruby bindings for the Intercom API
138
131
  test_files:
139
132
  - spec/integration/intercom_api_integration_spec.rb
@@ -147,3 +140,4 @@ test_files:
147
140
  - spec/unit/intercom/user_resource_spec.rb
148
141
  - spec/unit/intercom/user_spec.rb
149
142
  - spec/unit/intercom_spec.rb
143
+ has_rdoc: