intercom 3.0.6 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e53226896c0af5b1288ba4fa3ccd42d36a97acb9
4
- data.tar.gz: 6836b82a65fe0dc6e7da27cabbaa5047f9c89f5b
3
+ metadata.gz: 31f3539ed98058a5c24a7cf551db9526f5e1530d
4
+ data.tar.gz: 94d747068a98e5effc4fc3304e2b7d844c2e48bc
5
5
  SHA512:
6
- metadata.gz: 3440e69c84ec64f96921ac763b7751fce79671bae34d0bcbee80a65942890e2d6fb9fd80959285131e3c79460af611ccea42e1bcff30562b2d90373b16de1ee1
7
- data.tar.gz: 17d9779094ab97f45787ac590c1a18708c7075201990e60d91c7691fbe8a5d16466fc7ada2e32066c6cf715877e394f13bb23f0a312b5a5a3d2151aa945e5959
6
+ metadata.gz: b3ff736bf9162f1a4cafe237c72d8ef1ba5bce906cab9c9264376bba4d5c7c277f86f0e17259faa6950413363598d1b15562c099b15cffdef0ffea39ff401a6a
7
+ data.tar.gz: 156f6ca74ac7ca7bffb4367d9b0efb95ef889c1b36addecfe938b17552b75c58a3c07dc9c6ffbac5805fc2bba0de714333e73a8babe19d053ee4e93dd81bcf4b
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+ sudo: false
2
3
  rvm:
3
4
  - 2.1.0
4
5
  - 2.2.0
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.6"
25
+ gem 'intercom', "~> 3.1.0"
26
26
 
27
27
  ## Basic Usage
28
28
 
@@ -145,21 +145,21 @@ intercom.notes.find_all(:user_id => '123').each {|note| puts note.body}
145
145
  ```ruby
146
146
  # FINDING CONVERSATIONS FOR AN ADMIN
147
147
  # Iterate over all conversations (open and closed) assigned to an admin
148
- intercom.conversations.find_all(:type => 'admin', :id => '7').each do {|convo| ... }
148
+ intercom.conversations.find_all(:type => 'admin', :id => '7').each {|convo| ... }
149
149
  # Iterate over all open conversations assigned to an admin
150
- intercom.conversations.find_all(:type => 'admin', :id => 7, :open => true).each do {|convo| ... }
150
+ intercom.conversations.find_all(:type => 'admin', :id => 7, :open => true).each {|convo| ... }
151
151
  # Iterate over closed conversations assigned to an admin
152
- intercom.conversations.find_all(:type => 'admin', :id => 7, :open => false).each do {|convo| ... }
152
+ intercom.conversations.find_all(:type => 'admin', :id => 7, :open => false).each {|convo| ... }
153
153
  # Iterate over closed conversations for assigned an admin, before a certain moment in time
154
- intercom.conversations.find_all(:type => 'admin', :id => 7, :open => false, :before => 1374844930).each do {|convo| ... }
154
+ intercom.conversations.find_all(:type => 'admin', :id => 7, :open => false, :before => 1374844930).each {|convo| ... }
155
155
 
156
156
  # FINDING CONVERSATIONS FOR A USER
157
157
  # Iterate over all conversations (read + unread, correct) with a user based on the users email
158
- intercom.conversations.find_all(:email => 'joe@example.com', :type => 'user').each do {|convo| ... }
158
+ intercom.conversations.find_all(:email => 'joe@example.com', :type => 'user').each {|convo| ... }
159
159
  # Iterate over through all conversations (read + unread) with a user based on the users email
160
- intercom.conversations.find_all(:email => 'joe@example.com', :type => 'user', :unread => false).each do {|convo| ... }
160
+ intercom.conversations.find_all(:email => 'joe@example.com', :type => 'user', :unread => false).each {|convo| ... }
161
161
  # Iterate over all unread conversations with a user based on the users email
162
- intercom.conversations.find_all(:email => 'joe@example.com', :type => 'user', :unread => true).each do {|convo| ... }
162
+ intercom.conversations.find_all(:email => 'joe@example.com', :type => 'user', :unread => true).each {|convo| ... }
163
163
 
164
164
  # FINDING A SINGLE CONVERSATION
165
165
  conversation = intercom.conversations.find(:id => '1')
@@ -175,8 +175,26 @@ conversation.conversation_parts[1].body
175
175
  # REPLYING TO CONVERSATIONS
176
176
  # User (identified by email) replies with a comment
177
177
  intercom.conversations.reply(:id => conversation.id, :type => 'user', :email => 'joe@example.com', :message_type => 'comment', :body => 'foo')
178
- # Admin (identified by email) replies with a comment
179
- intercom.conversations.reply(:id => conversation.id, :type => 'admin', :email => 'bob@example.com', :message_type => 'comment', :body => 'bar')
178
+ # Admin (identified by id) replies with a comment
179
+ intercom.conversations.reply(:id => conversation.id, :type => 'admin', :admin_id => '123', :message_type => 'comment', :body => 'bar')
180
+
181
+ # Open
182
+ intercom.conversations.open(id: conversation.id, admin_id: '123')
183
+
184
+ # Close
185
+ intercom.conversations.close(id: conversation.id, admin_id: '123')
186
+
187
+ # Assign
188
+ intercom.conversations.assign(id: conversation.id, admin_id: '123', assignee_id: '124')
189
+
190
+ # Reply and Open
191
+ intercom.conversations.reply(:id => conversation.id, :type => 'admin', :admin_id => '123', :message_type => 'open', :body => 'bar')
192
+
193
+ # Reply and Close
194
+ intercom.conversations.reply(:id => conversation.id, :type => 'admin', :admin_id => '123', :message_type => 'close', :body => 'bar')
195
+
196
+ # ASSIGNING CONVERSATIONS TO ADMINS
197
+ intercom.conversations.reply(:id => conversation.id, :type => 'admin', :assignee_id => assignee_admin.id, :admin_id => admin.id, :message_type => 'assignment')
180
198
 
181
199
  # MARKING A CONVERSATION AS READ
182
200
  intercom.conversations.mark_read(conversation.id)
data/changes.txt CHANGED
@@ -1,3 +1,6 @@
1
+ 3.1.0
2
+ - Support opening, closing, and assigning conversations
3
+
1
4
  3.0.6
2
5
  - Support the `delete` resource on Contacts
3
6
 
@@ -26,6 +26,19 @@ module Intercom
26
26
  response = @client.post("/#{collection_name}/#{id}/reply", reply_data.merge(:conversation_id => id))
27
27
  collection_class.new.from_response(response)
28
28
  end
29
+
30
+ def open(reply_data)
31
+ reply reply_data.merge(message_type: 'open', type: 'admin')
32
+ end
33
+
34
+ def close(reply_data)
35
+ reply reply_data.merge(message_type: 'close', type: 'admin')
36
+ end
37
+
38
+ def assign(reply_data)
39
+ assignee_id = reply_data.fetch(:assignee_id) { fail 'assignee_id is required' }
40
+ reply reply_data.merge(message_type: 'assignment', assignee_id: assignee_id, type: 'admin')
41
+ end
29
42
  end
30
43
  end
31
44
  end
@@ -1,3 +1,3 @@
1
1
  module Intercom #:nodoc:
2
- VERSION = "3.0.6"
2
+ VERSION = "3.1.0"
3
3
  end
@@ -18,6 +18,21 @@ describe "Intercom::Conversation" do
18
18
  client.conversations.reply(id: '147', type: 'user', body: 'Thanks again', message_type: 'comment', user_id: 'ac4')
19
19
  end
20
20
 
21
+ it 'opens a conversation' do
22
+ client.expects(:post).with('/conversations/147/reply', { type: 'admin', message_type: 'open', conversation_id: '147', admin_id: '123'}).returns(test_conversation)
23
+ client.conversations.open(id: '147', admin_id: '123')
24
+ end
25
+
26
+ it 'closes a conversation' do
27
+ client.expects(:post).with('/conversations/147/reply', { type: 'admin', message_type: 'close', conversation_id: '147', admin_id: '123'}).returns(test_conversation)
28
+ client.conversations.close(id: '147', admin_id: '123')
29
+ end
30
+
31
+ it 'assigns a conversation' do
32
+ client.expects(:post).with('/conversations/147/reply', { type: 'admin', message_type: 'assignment', conversation_id: '147', admin_id: '123', assignee_id: '124'}).returns(test_conversation)
33
+ client.conversations.assign(id: '147', admin_id: '123', assignee_id: '124')
34
+ end
35
+
21
36
  # it "creates a subscription" do
22
37
  # client.expects(:post).with("/subscriptions", {'url' => "http://example.com", 'topics' => ["user.created"]}).returns(test_subscription)
23
38
  # subscription = client.subscriptions.create(:url => "http://example.com", :topics => ["user.created"])
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.6
4
+ version: 3.1.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-07-14 00:00:00.000000000 Z
18
+ date: 2015-07-29 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: minitest