intercom 3.1.0 → 3.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31f3539ed98058a5c24a7cf551db9526f5e1530d
4
- data.tar.gz: 94d747068a98e5effc4fc3304e2b7d844c2e48bc
3
+ metadata.gz: d5ef9d6fa028f29130786bb4e260112ddbbce668
4
+ data.tar.gz: 23112e23cdf9f44f20d4a55d20bf7070aae80385
5
5
  SHA512:
6
- metadata.gz: b3ff736bf9162f1a4cafe237c72d8ef1ba5bce906cab9c9264376bba4d5c7c277f86f0e17259faa6950413363598d1b15562c099b15cffdef0ffea39ff401a6a
7
- data.tar.gz: 156f6ca74ac7ca7bffb4367d9b0efb95ef889c1b36addecfe938b17552b75c58a3c07dc9c6ffbac5805fc2bba0de714333e73a8babe19d053ee4e93dd81bcf4b
6
+ metadata.gz: 3e1c851b4481a5a17faf27240766e94b0b92060d0758e079a7f04cac11a9eb1725710b3744149d263737903f0c805d8cdf405d95d7bab8e36106ebe25e814672
7
+ data.tar.gz: ab37cc7e537610f7fb6748dab499b975a1926043aac9ba313c15a7f097db5aec8ecf6611458675bf7aa716527903d55cb5534227a1e2afd97d9f5bc6c0e49df7
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.1.0"
25
+ gem 'intercom', "~> 3.2.0"
26
26
 
27
27
  ## Basic Usage
28
28
 
@@ -177,6 +177,8 @@ conversation.conversation_parts[1].body
177
177
  intercom.conversations.reply(:id => conversation.id, :type => 'user', :email => 'joe@example.com', :message_type => 'comment', :body => 'foo')
178
178
  # Admin (identified by id) replies with a comment
179
179
  intercom.conversations.reply(:id => conversation.id, :type => 'admin', :admin_id => '123', :message_type => 'comment', :body => 'bar')
180
+ # User (identified by email) replies with a comment and attachment
181
+ intercom.conversations.reply(:id => conversation.id, :type => 'user', :email => 'joe@example.com', :message_type => 'comment', :body => 'foo', :attachment => ['http://www.example.com/attachment.jpg'])
180
182
 
181
183
  # Open
182
184
  intercom.conversations.open(id: conversation.id, admin_id: '123')
@@ -333,7 +335,7 @@ contacts = intercom.contacts.find_all(email: "some_contact@example.com")
333
335
  intercom.contacts.convert(contact, user)
334
336
 
335
337
  # Delete a contact
336
- intercom.contacts.find(id: "some_id").delete
338
+ intercom.contacts.delete(contact)
337
339
  ```
338
340
 
339
341
  ### Counts
@@ -1,3 +1,7 @@
1
+ 3.2.0
2
+ - Add attachment support for conversations
3
+ - Fix puts'ing api resources
4
+
1
5
  3.1.0
2
6
  - Support opening, closing, and assigning conversations
3
7
 
@@ -18,7 +18,7 @@ module Intercom
18
18
  Lib::DynamicAccessors.define_accessors(attribute_name, *arguments, object)
19
19
  object.send(method_sym, *arguments)
20
20
  else # getter
21
- if trying_to_access_private_variable?
21
+ if trying_to_access_private_variable? || trying_to_access_print_method?
22
22
  yield
23
23
  else
24
24
  raise Intercom::AttributeNotSetError, attribute_not_set_error_message
@@ -44,6 +44,10 @@ module Intercom
44
44
  object.instance_variable_defined?("@#{method_string}")
45
45
  end
46
46
 
47
+ def trying_to_access_print_method?
48
+ [:to_ary, :to_s].include? method_sym
49
+ end
50
+
47
51
  def attribute_not_set_error_message
48
52
  "'#{method_string}' called on #{klass} but it has not been set an " +
49
53
  "attribute or does not exist as a method"
@@ -136,7 +136,7 @@ module Intercom
136
136
  case error_code
137
137
  when 'unauthorized', 'forbidden'
138
138
  raise Intercom::AuthenticationError.new(error_details['message'], error_context)
139
- when "bad_request", "missing_parameter", 'parameter_invalid'
139
+ when "bad_request", "missing_parameter", 'parameter_invalid', 'parameter_not_found'
140
140
  raise Intercom::BadRequestError.new(error_details['message'], error_context)
141
141
  when "not_found"
142
142
  raise Intercom::ResourceNotFound.new(error_details['message'], error_context)
@@ -144,7 +144,7 @@ module Intercom
144
144
  raise Intercom::RateLimitExceeded.new(error_details['message'], error_context)
145
145
  when 'service_unavailable'
146
146
  raise Intercom::ServiceUnavailableError.new(error_details['message'], error_context)
147
- when 'conflict'
147
+ when 'conflict', 'unique_user_constraint'
148
148
  raise Intercom::MultipleMatchingUsersError.new(error_details['message'], error_context)
149
149
  when nil, ''
150
150
  raise Intercom::UnexpectedError.new(message_for_unexpected_error_without_type(error_details, parsed_http_code), error_context)
@@ -1,3 +1,3 @@
1
1
  module Intercom #:nodoc:
2
- VERSION = "3.1.0"
2
+ VERSION = "3.2.0"
3
3
  end
@@ -18,6 +18,11 @@ 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 'replies to a conversation with an attachment' do
22
+ client.expects(:post).with('/conversations/147/reply', { type: 'user', body: 'Thanks again', message_type: 'comment', user_id: 'ac4', conversation_id: '147', attachment_urls: ["http://www.example.com/attachment.jpg"] }).returns(test_conversation)
23
+ client.conversations.reply(id: '147', type: 'user', body: 'Thanks again', message_type: 'comment', user_id: 'ac4', attachment_urls: ["http://www.example.com/attachment.jpg"])
24
+ end
25
+
21
26
  it 'opens a conversation' do
22
27
  client.expects(:post).with('/conversations/147/reply', { type: 'admin', message_type: 'open', conversation_id: '147', admin_id: '123'}).returns(test_conversation)
23
28
  client.conversations.open(id: '147', admin_id: '123')
@@ -235,4 +235,11 @@ describe "Intercom::User" do
235
235
  all.must_be_instance_of(Intercom::ClientCollectionProxy)
236
236
  end
237
237
 
238
+ it 'can print users without crashing' do
239
+ client.expects(:get).with("/users", {"email" => "bo@example.com"}).returns(test_user)
240
+ user = client.users.find("email" => "bo@example.com")
241
+ puts user
242
+ p user
243
+ end
244
+
238
245
  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.1.0
4
+ version: 3.2.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-29 00:00:00.000000000 Z
18
+ date: 2015-09-16 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: minitest