recurly 3.2.1 → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bumpversion.cfg +1 -1
- data/lib/recurly/client.rb +17 -17
- data/lib/recurly/schema/json_parser.rb +4 -4
- data/lib/recurly/schema/request_caster.rb +14 -14
- data/lib/recurly/schema/resource_caster.rb +9 -9
- data/lib/recurly/schema/schema_validator.rb +9 -9
- data/lib/recurly/version.rb +1 -1
- data/recurly.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1182927b43b3f1815fc6e5fbdc029e655d5310898044087cdaa297e53c3a13ce
|
4
|
+
data.tar.gz: 39fb2a708a7beba058967282ecd06a7713ed2ad62397ce86a73998fdc2f0542c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62e800e4c9ca3a1802f24bf46801e86e4bece4b462da4f362a49b8c6f93166ed5364cca83c6999b58fad38b3d5a175d6fc75f12d9d5e381b81410017f9c426e7
|
7
|
+
data.tar.gz: 4f5df171887b926abd2142d3b79f43beaee6ec4d17cb2481dfc374a4dbab59b4122fc7df3a7216a7f4ca1b9d1f44080054f3aca47f56c2a379da18d7dd20f342
|
data/.bumpversion.cfg
CHANGED
data/lib/recurly/client.rb
CHANGED
@@ -126,14 +126,14 @@ module Recurly
|
|
126
126
|
response = HTTP::Response.new(faraday_resp, request)
|
127
127
|
raise_api_error!(response) unless (200...300).include?(response.status)
|
128
128
|
resource = if response.body
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
129
|
+
if BINARY_TYPES.include?(response.content_type)
|
130
|
+
FileParser.parse(response.body)
|
131
|
+
else
|
132
|
+
JSONParser.parse(self, response.body)
|
133
|
+
end
|
134
|
+
else
|
135
|
+
Resources::Empty.new
|
136
|
+
end
|
137
137
|
# Keep this interface "private"
|
138
138
|
resource.instance_variable_set(:@response, response)
|
139
139
|
resource
|
@@ -141,15 +141,15 @@ module Recurly
|
|
141
141
|
|
142
142
|
def raise_network_error!(ex)
|
143
143
|
error_class = case ex
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
144
|
+
when Faraday::TimeoutError
|
145
|
+
Errors::TimeoutError
|
146
|
+
when Faraday::ConnectionFailed
|
147
|
+
Errors::ConnectionFailedError
|
148
|
+
when Faraday::SSLError
|
149
|
+
Errors::SSLError
|
150
|
+
else
|
151
|
+
Errors::NetworkError
|
152
|
+
end
|
153
153
|
|
154
154
|
raise error_class, ex.message
|
155
155
|
end
|
@@ -27,10 +27,10 @@ module Recurly
|
|
27
27
|
# @return [Error,Resource]
|
28
28
|
def self.from_json(data)
|
29
29
|
type = if data.has_key?("error")
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
"error_may_have_transaction"
|
31
|
+
else
|
32
|
+
data["object"]
|
33
|
+
end
|
34
34
|
klazz = self.recurly_class(type)
|
35
35
|
|
36
36
|
unless klazz
|
@@ -35,20 +35,20 @@ module Recurly
|
|
35
35
|
data.each do |k, v|
|
36
36
|
schema_attr = schema.get_attribute(k)
|
37
37
|
norm_val = if v.respond_to?(:attributes)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
38
|
+
cast_request(v, v.class.schema)
|
39
|
+
elsif v.is_a?(Array)
|
40
|
+
v.map do |elem|
|
41
|
+
if elem.respond_to?(:attributes)
|
42
|
+
cast_request(elem, elem.class.schema)
|
43
|
+
else
|
44
|
+
elem
|
45
|
+
end
|
46
|
+
end
|
47
|
+
elsif v.is_a?(Hash) && schema_attr && schema_attr.is_a?(Schema::ResourceAttribute)
|
48
|
+
cast_request(v, schema_attr.recurly_class.schema)
|
49
|
+
else
|
50
|
+
v
|
51
|
+
end
|
52
52
|
|
53
53
|
casted[k] = norm_val
|
54
54
|
end
|
@@ -23,15 +23,15 @@ module Recurly
|
|
23
23
|
|
24
24
|
if schema_attr
|
25
25
|
val = if val.nil?
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
val
|
27
|
+
elsif schema_attr.is_valid?(val)
|
28
|
+
schema_attr.cast(val)
|
29
|
+
else
|
30
|
+
if Recurly::STRICT_MODE
|
31
|
+
msg = "#{self.class}##{attr_name} does not have the right type. Value: #{val.inspect} was expected to be a #{schema_attr}"
|
32
|
+
raise ArgumentError, msg
|
33
|
+
end
|
34
|
+
end
|
35
35
|
|
36
36
|
writer = "#{attr_name}="
|
37
37
|
resource.send(writer, val)
|
@@ -39,11 +39,11 @@ module Recurly
|
|
39
39
|
# will take care of it for us
|
40
40
|
unless safely_castable?(val.class, schema_attr.type)
|
41
41
|
expected = case schema_attr
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
42
|
+
when Schema::ArrayAttribute
|
43
|
+
"Array of #{schema_attr.type}s"
|
44
|
+
else
|
45
|
+
schema_attr.type
|
46
|
+
end
|
47
47
|
|
48
48
|
raise ArgumentError, "Attribute '#{name}' on the resource #{self.class.name} is type #{val.class} but should be a #{expected}"
|
49
49
|
end
|
@@ -73,10 +73,10 @@ module Recurly
|
|
73
73
|
def safely_castable?(from_type, to_type)
|
74
74
|
# TODO we can drop this switch when 2.3 support is dropped
|
75
75
|
int_class = if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.4.0")
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
76
|
+
:Integer
|
77
|
+
else
|
78
|
+
:Fixnum
|
79
|
+
end
|
80
80
|
int_class = Kernel.const_get(int_class)
|
81
81
|
|
82
82
|
case [from_type, to_type]
|
data/lib/recurly/version.rb
CHANGED
data/recurly.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
# spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_dependency "faraday", ">= 0.8.11", "< 0.
|
24
|
+
spec.add_dependency "faraday", ">= 0.8.11", "< 1.0.0"
|
25
25
|
|
26
26
|
spec.add_development_dependency "net-http-persistent", "~> 2.9.4"
|
27
27
|
spec.add_development_dependency "bundler", "~> 2.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recurly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Recurly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 0.8.11
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 1.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 0.8.11
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 1.0.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: net-http-persistent
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -315,7 +315,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
315
315
|
- !ruby/object:Gem::Version
|
316
316
|
version: '0'
|
317
317
|
requirements: []
|
318
|
-
rubygems_version: 3.0.
|
318
|
+
rubygems_version: 3.0.6
|
319
319
|
signing_key:
|
320
320
|
specification_version: 4
|
321
321
|
summary: The ruby client for Recurly's V3 API
|