paid 1.1.4 → 1.2.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: 70fd01f1b198131d9ad8dc724f84b2d2ceb8a657
4
- data.tar.gz: 1276983666dbd59141b11afaa22f4df492b4288c
3
+ metadata.gz: c9bad5d3576a96f19db1fbc05ccf224c9c8397de
4
+ data.tar.gz: 637c1c73672a9ca3122b7a843a63f83581058cac
5
5
  SHA512:
6
- metadata.gz: 722631a43e1fa30520c084c255502896fbcc9f431c0b94f1826167e13bb3e13c8c80cbe43ad332bc9379cdf76af70764f7e62a195522b111b0823deaec98e920
7
- data.tar.gz: 47576c6efc7655a8491ce854e9db9fd71ec1e3662f870f96ea97a7d9204e401be42892cfa38c41b42e5cb51059c1331435dfd31f14f26ff23d06dcaf6148bd5b
6
+ metadata.gz: 346aa1f1fbd0fa00dfee391c342683d51f4f932d1967d07c30f6010cc07de251458c7932cd13871195246ebd0612bbde20d21a075cfc33ac1f513db732371267
7
+ data.tar.gz: a9cb615bf5c3ce34deb33b9f4121edee4fe466a37a0be2adac10b05b2eb7ae6b8f8dd3638ded1ed23dc21348e6098176a9e409d2cd99b8b9621e4bf692ae6999
@@ -5,6 +5,9 @@ rvm:
5
5
  - 2.0.0
6
6
  - 2.1
7
7
  - 2.2
8
+ - 2.2.2
9
+ - 2.3.0
10
+ - 2.4.0
8
11
 
9
12
  gemfile:
10
13
  - gemfiles/default-with-activesupport.gemfile
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source "https://rubygems.org"
2
2
  gemspec
3
3
 
4
- if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('1.9.3')
4
+ if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.2.2')
5
5
  gem 'i18n', '< 0.7'
6
6
  gem 'rest-client', '~> 1.6.8'
7
7
  gem 'activesupport', '~> 3.2'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.4
1
+ 1.2.0
@@ -1,7 +1,7 @@
1
1
  source "https://rubygems.org"
2
2
  gemspec :path => File.join(File.dirname(__FILE__), "..")
3
3
 
4
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.3')
4
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.2')
5
5
  gem 'i18n', '< 0.7'
6
6
  gem 'rest-client', '~> 1.6.8'
7
7
  gem 'activesupport', '~> 3.2'
@@ -1,7 +1,7 @@
1
1
  source "https://rubygems.org"
2
2
  gemspec :path => File.join(File.dirname(__FILE__), "..")
3
3
 
4
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.3')
4
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.2')
5
5
  gem 'i18n', '< 0.7'
6
6
  gem 'rest-client', '~> 1.6.8'
7
7
  gem 'activesupport', '~> 3.2'
@@ -1,7 +1,7 @@
1
1
  source "https://rubygems.org"
2
2
  gemspec :path => File.join(File.dirname(__FILE__), "..")
3
3
 
4
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.3')
4
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.2')
5
5
  gem 'i18n', '< 0.7'
6
6
  gem 'rest-client', '~> 1.6.8'
7
7
  gem 'activesupport', '~> 3.2'
@@ -84,15 +84,20 @@ module Paid
84
84
 
85
85
  # Handle a few common cases.
86
86
  def error_with_response(error)
87
+ message = begin
88
+ response_json[:error][:message]
89
+ rescue
90
+ nil
91
+ end
92
+
93
+ message ||= error.message
94
+
87
95
  case @response_code
88
- when 400, 404
89
- return APIError.new("Invalid request. Please check the URL and parameters.", self)
90
96
  when 401
91
- return AuthenticationError.new("Authentication failed. Please check your API key and verify that it is correct.", self)
97
+ return AuthenticationError.new(message, self)
92
98
  else
93
- return APIError.new("An error occured while making the API call.", self)
99
+ return APIError.new(message, self)
94
100
  end
95
101
  end
96
-
97
102
  end
98
103
  end
@@ -2,8 +2,8 @@ module Paid
2
2
  class APIError < PaidError
3
3
  attr_reader :api_method
4
4
 
5
- def initialize(message=nil, api_method=nil)
6
- @message = message
5
+ def initialize(message = nil, api_method = nil)
6
+ @message = message || response_message
7
7
  @api_method = api_method
8
8
  end
9
9
 
@@ -23,10 +23,20 @@ module Paid
23
23
  end
24
24
  end
25
25
 
26
+ def response_message
27
+ begin
28
+ json[:error][:message]
29
+ rescue
30
+ nil
31
+ end
32
+ end
33
+
26
34
  def to_s
27
- prefix = code.nil? ? "" : "(Status #{code}) "
28
- suffix = " JSON: #{JSON.pretty_generate(json)}" if json
29
- "#{prefix}#{@message}" + (json ? suffix : "")
35
+ if code.nil?
36
+ return @message
37
+ else
38
+ return "(Status #{code}) #{@message}"
39
+ end
30
40
  end
31
41
  end
32
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Calhoun
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-12 00:00:00.000000000 Z
12
+ date: 2017-04-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
207
  version: '0'
208
208
  requirements: []
209
209
  rubyforge_project:
210
- rubygems_version: 2.4.5
210
+ rubygems_version: 2.6.8
211
211
  signing_key:
212
212
  specification_version: 4
213
213
  summary: Ruby bindings for Paid API