customerio 0.6.0 → 0.6.1

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzQwYTIwYmZjMDliN2UzNGU0ZGVjOWFlYmEyMGI0MTFiNWExNDViYQ==
4
+ ZTZjMjYyNzc2NDA2ZjViNGM3YzY0MjM2ZmU1MGNkZmRmOTRmNmYzOA==
5
5
  data.tar.gz: !binary |-
6
- M2JhZDY0NDQyNTBiMmU4NjBkOGZlNGU3NWM4YzM4ZGRlMDUxYWI2YQ==
6
+ NzljMDM4NjY5ZDljN2MwOTYyMWMzOGFiYzFiOGEzNjM5ZTgyMjc1MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjAyNzRiM2NiMTNiYmZhYjZiOTk4MjAxZWIyMzk3MWMwNjdlZjk2NzBhOTIw
10
- MmE4ZmUzNTMzZWE0NDNmY2NiMjNmOGU1NDMyMTdiNzY1YzhhOGY4MDE5NWJl
11
- ZWVkNWU3YTk2OTAxNzI1NGIwM2U5ZTVjMzJiZjdiNWU3YWZkMDQ=
9
+ YmQzNDE4OTMyMTFmODE0NWNkMTc4NGYzYmZkNjJkMjlkZTVlNTBkYTIyNWE4
10
+ YWVkMTA5NzBmNjkxZTEzZTNkMmFmNDRlNTlkNWRhNTQ0NzM3ZTM5YzlhYTAy
11
+ ODg2OWU3ZWQ4MjcwY2IwODY4Mzk2ODdjM2UxNDkyNzNkZDUxODQ=
12
12
  data.tar.gz: !binary |-
13
- NGM4NjAwYjdiZjlhZGZkMWRkZjg2MWU1MGM2OGIxNjU1MjM2ZDk2ZjhjNjgz
14
- MjlkYzE0ODdhZjM2ZmZkMWZhYzE2ZThlMzE4ZTg2MDdiYTQwYzg0MmY0Y2Uw
15
- M2JkYWVlY2U3MDQ0NzNlNTcxOTgyNTU0NTZmMTZkMjliM2FjNzM=
13
+ NGU3MjIzNDFjN2ZiN2I5MmZiY2FlY2YwNGU5MjE0OGFkZjJjY2RhNDc5NmM5
14
+ NDNmMDFlMjI2N2Q0YjEzZWQ1ZGRiYjY3MzE1YTg1ZDFhNjZiZTY0MGMzYjI5
15
+ ODYxZDQ4OTZmMTc5NDU3MmRmNDNmNDQyNzViZmVkYzQ1OWIzZjc=
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,17 @@
1
+ ## Customerio 0.6.1 - Oct 8, 2015 ##
2
+
3
+ * Include HTTP response as an attribute on the InvalidResponse exception to help with debugging failed API requests. For example:
4
+
5
+ ```ruby
6
+ begin
7
+ $customerio.track(1, 'event', { :test => 'testing' })
8
+ rescue => e
9
+ puts e.message
10
+ puts e.response.status
11
+ puts e.response.body
12
+ end
13
+ ```
14
+
1
15
  ## Customerio 0.6.0 - Oct 6, 2015 ##
2
16
 
3
17
  Deprecation warning: we are going to switch to JSON encoding by default for the next release. The current default is form-encoding. This will probably not affect you, unless you rely on how form-encoding arrays work.
@@ -8,7 +8,14 @@ module Customerio
8
8
  default_timeout 10
9
9
 
10
10
  class MissingIdAttributeError < RuntimeError; end
11
- class InvalidResponse < RuntimeError; end
11
+ class InvalidResponse < RuntimeError
12
+ attr_reader :response
13
+
14
+ def initialize(message, response)
15
+ @message = message
16
+ @response = response
17
+ end
18
+ end
12
19
 
13
20
  def initialize(site_id, secret_key, options = {})
14
21
  @auth = { :username => site_id, :password => secret_key }
@@ -89,7 +96,7 @@ module Customerio
89
96
  if response.code >= 200 && response.code < 300
90
97
  response
91
98
  else
92
- raise InvalidResponse.new("Customer.io API returned an invalid response: #{response.code}")
99
+ raise InvalidResponse.new("Customer.io API returned an invalid response: #{response.code}", response)
93
100
  end
94
101
  end
95
102
 
@@ -1,3 +1,3 @@
1
1
  module Customerio
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -40,6 +40,15 @@ describe Customerio::Client do
40
40
  lambda { client.identify(:id => 5) }.should raise_error(Customerio::Client::InvalidResponse)
41
41
  end
42
42
 
43
+ it "includes the HTTP response with raised errors" do
44
+ response = double("Response", :code => 500, :body => "whatever")
45
+ Customerio::Client.should_receive(:put).and_return(response)
46
+ lambda { client.identify(:id => 5) }.should raise_error {|error|
47
+ error.should be_a Customerio::Client::InvalidResponse
48
+ error.response.should eq response
49
+ }
50
+ end
51
+
43
52
  it "uses the site_id and api key for basic auth" do
44
53
  Customerio::Client.should_receive(:put).with("/api/v1/customers/5", {
45
54
  :basic_auth => { :username => "SITE_ID", :password => "API_KEY" },
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: customerio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Allison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-07 00:00:00.000000000 Z
11
+ date: 2015-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty