iron_bank 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/iron_bank/action.rb +21 -2
- data/lib/iron_bank/error.rb +4 -0
- data/lib/iron_bank/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db077e1c6186fc1a24bd7d1ae7cf06e6c9c02a85acb8a651e6c5c84e7a3972c7
|
4
|
+
data.tar.gz: 84903d8e3515bd8b48b192e32d1cfc6293a7d0c99ea709c4c7106d609db646cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8afcf559e8a4a0b7c0a70bb4d8faabf179a394a939c6993ae0cdea76c06a1a5f3bf889201af394169e71b1ee119f394460a7c0e5636084198993e847f7d3f82b
|
7
|
+
data.tar.gz: f9aa741b2ea5b469512e5285db6ecf19fc8c63762b4581bdb29e7803b8b53a3a7dbf3d8dc059bd609d219619c5f7d21dd6a35c5e7ec14eaee08effc3b9ed9de4
|
data/lib/iron_bank/action.rb
CHANGED
@@ -11,12 +11,15 @@ module IronBank
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def call
|
14
|
-
IronBank.client.connection.post(endpoint, params).body
|
14
|
+
@body = IronBank.client.connection.post(endpoint, params).body
|
15
|
+
return body if success?
|
16
|
+
|
17
|
+
raise ::IronBank::UnprocessableEntity, errors
|
15
18
|
end
|
16
19
|
|
17
20
|
private
|
18
21
|
|
19
|
-
attr_reader :args
|
22
|
+
attr_reader :args, :body
|
20
23
|
|
21
24
|
def initialize(args)
|
22
25
|
@args = args
|
@@ -30,6 +33,22 @@ module IronBank
|
|
30
33
|
self.class.name.split('::').last
|
31
34
|
end
|
32
35
|
|
36
|
+
def success?
|
37
|
+
response_object.fetch(:success, true)
|
38
|
+
end
|
39
|
+
|
40
|
+
def response_object
|
41
|
+
@response_object ||= begin
|
42
|
+
return {} unless body.is_a?(Array)
|
43
|
+
|
44
|
+
::IronBank::Object.new(body.first).deep_underscore
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def errors
|
49
|
+
{ errors: response_object.fetch(:errors, []) }
|
50
|
+
end
|
51
|
+
|
33
52
|
def requests(type: :upper)
|
34
53
|
args.fetch(:objects).map do |object|
|
35
54
|
IronBank::Object.new(object).deep_camelize(type: type)
|
data/lib/iron_bank/error.rb
CHANGED
@@ -12,6 +12,7 @@ module IronBank
|
|
12
12
|
case status
|
13
13
|
when 400 then IronBank::BadRequest
|
14
14
|
when 404 then IronBank::NotFound
|
15
|
+
when 422 then IronBank::UnprocessableEntity
|
15
16
|
when 429 then IronBank::TooManyRequests
|
16
17
|
when 500 then IronBank::InternalServerError
|
17
18
|
when 400..499 then IronBank::ClientError
|
@@ -34,6 +35,9 @@ module IronBank
|
|
34
35
|
# Raised when Zuora returns a 404 HTTP status code
|
35
36
|
class NotFound < ClientError; end
|
36
37
|
|
38
|
+
# Raised when Zuora return 422 and unsuccessful action responses
|
39
|
+
class UnprocessableEntity < Error; end
|
40
|
+
|
37
41
|
# Raised when Zuora returns a 429 HTTP status code
|
38
42
|
class TooManyRequests < ClientError; end
|
39
43
|
|
data/lib/iron_bank/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iron_bank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mickael Pham
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2018-10-
|
14
|
+
date: 2018-10-05 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bump
|