paid 1.1.4 → 1.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 +4 -4
- data/.travis.yml +3 -0
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/gemfiles/default-with-activesupport.gemfile +1 -1
- data/gemfiles/json.gemfile +1 -1
- data/gemfiles/yajl.gemfile +1 -1
- data/lib/paid/api_method.rb +10 -5
- data/lib/paid/errors/api_error.rb +15 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9bad5d3576a96f19db1fbc05ccf224c9c8397de
|
4
|
+
data.tar.gz: 637c1c73672a9ca3122b7a843a63f83581058cac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 346aa1f1fbd0fa00dfee391c342683d51f4f932d1967d07c30f6010cc07de251458c7932cd13871195246ebd0612bbde20d21a075cfc33ac1f513db732371267
|
7
|
+
data.tar.gz: a9cb615bf5c3ce34deb33b9f4121edee4fe466a37a0be2adac10b05b2eb7ae6b8f8dd3638ded1ed23dc21348e6098176a9e409d2cd99b8b9621e4bf692ae6999
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
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('
|
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'
|
data/gemfiles/json.gemfile
CHANGED
@@ -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('
|
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'
|
data/gemfiles/yajl.gemfile
CHANGED
@@ -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('
|
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'
|
data/lib/paid/api_method.rb
CHANGED
@@ -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(
|
97
|
+
return AuthenticationError.new(message, self)
|
92
98
|
else
|
93
|
-
return APIError.new(
|
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
|
-
|
28
|
-
|
29
|
-
|
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.
|
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:
|
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.
|
210
|
+
rubygems_version: 2.6.8
|
211
211
|
signing_key:
|
212
212
|
specification_version: 4
|
213
213
|
summary: Ruby bindings for Paid API
|