zaala 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zaala/api/client.rb +25 -56
- data/lib/zaala/api/types.rb +0 -3
- 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: f0a55d072af2dd4980af6bfe06f3345be59669e8ad2224da59a14eac7731dce9
|
4
|
+
data.tar.gz: 8027aedf2cf15235ab8cba315194c99223bef37ff66e61c1b74f516dec8e5837
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 502496d79d807838df293c5be15649cf6dccd4830a872e5fe685b746e294e26a65db99509e9cb731cadb2281cd0e57368803f4322b00e5333e27640b044100ad
|
7
|
+
data.tar.gz: 94c4926c4977ae3fc616594b18ce4befad3fcce6ad038b0303694b9e587eb2a0c332cfa28e329a49ae43c098f83f1634c02e26cc58eaf9d414757dc58e60dd20
|
data/lib/zaala/api/client.rb
CHANGED
@@ -43,15 +43,8 @@ module Zaala::API
|
|
43
43
|
ensure_operation_exists(:pre_authorize)
|
44
44
|
raise BadRequestError.new("pre_authorize operation requires an AuthorizationRequest parameter") unless req.is_a?(AuthorizationRequest)
|
45
45
|
|
46
|
-
res =
|
47
|
-
message(authorizationRequest: req.to_message)
|
48
|
-
end
|
46
|
+
res = call(:pre_authorize, authorizationRequest: req.to_message)
|
49
47
|
AuthorizationResponse.from_message(res.body[:preAuthorizeResponse][:return])
|
50
|
-
rescue Savon::SOAPFault => e
|
51
|
-
# Extract bad request errors
|
52
|
-
maybe_raise_invalid_fields(e.to_hash[:Fault])
|
53
|
-
# Fallback to standard errro
|
54
|
-
raise StandardError, e.to_hash.dig(:Fault, :faultstring)
|
55
48
|
end
|
56
49
|
|
57
50
|
# Authorizes a purchase transaction.
|
@@ -59,15 +52,8 @@ module Zaala::API
|
|
59
52
|
ensure_operation_exists(:authorize)
|
60
53
|
raise BadRequestError.new("authorize operation requires an AuthorizationRequest parameter") unless req.is_a?(AuthorizationRequest)
|
61
54
|
|
62
|
-
res =
|
63
|
-
message(authorizationRequest: req.to_message)
|
64
|
-
end
|
55
|
+
res = call(:authorize, authorizationRequest: req.to_message)
|
65
56
|
AuthorizationResponse.from_message(res.body[:authorizeResponse][:return])
|
66
|
-
rescue Savon::SOAPFault => e
|
67
|
-
# Extract bad request errors
|
68
|
-
maybe_raise_invalid_fields(e.to_hash[:Fault])
|
69
|
-
# Fallback to standard errro
|
70
|
-
raise StandardError, e.to_hash.dig(:Fault, :faultstring)
|
71
57
|
end
|
72
58
|
|
73
59
|
# Cancel a previous reservation of funds.
|
@@ -75,15 +61,8 @@ module Zaala::API
|
|
75
61
|
ensure_operation_exists(:cancel_authorization)
|
76
62
|
raise BadRequestError.new("cancel_authorization operation requires a CancellationRequest parameter") unless req.is_a?(CancellationRequest)
|
77
63
|
|
78
|
-
res =
|
79
|
-
message(cancellationRequest: req.to_message)
|
80
|
-
end
|
64
|
+
res = call(:cancel_authorization, cancellationRequest: req.to_message)
|
81
65
|
CancellationResponse.from_message(res.body[:cancelAuthorizationResponse][:return])
|
82
|
-
rescue Savon::SOAPFault => e
|
83
|
-
# Extract bad request errors
|
84
|
-
maybe_raise_invalid_fields(e.to_hash[:Fault])
|
85
|
-
# Fallback to standard errro
|
86
|
-
raise StandardError, e.to_hash.dig(:Fault, :faultstring)
|
87
66
|
end
|
88
67
|
|
89
68
|
# Perform a solvency check.
|
@@ -91,15 +70,8 @@ module Zaala::API
|
|
91
70
|
ensure_operation_exists(:check)
|
92
71
|
raise BadRequestError.new("check operation requires a CheckRequest parameter") unless req.is_a?(CheckRequest)
|
93
72
|
|
94
|
-
res =
|
95
|
-
message(checkRequest: req.to_message)
|
96
|
-
end
|
73
|
+
res = call(:check, checkRequest: req.to_message)
|
97
74
|
CheckResponse.from_message(res.body[:checkResponse][:return])
|
98
|
-
rescue Savon::SOAPFault => e
|
99
|
-
# Extract bad request errors
|
100
|
-
maybe_raise_invalid_fields(e.to_hash[:Fault])
|
101
|
-
# Fallback to standard errro
|
102
|
-
raise StandardError, e.to_hash.dig(:Fault, :faultstring)
|
103
75
|
end
|
104
76
|
|
105
77
|
# Returns available information about an authorization-ID.
|
@@ -107,15 +79,8 @@ module Zaala::API
|
|
107
79
|
ensure_operation_exists(:info)
|
108
80
|
raise BadRequestError.new("info operation requires an InfoRequest parameter") unless req.is_a?(InfoRequest)
|
109
81
|
|
110
|
-
res =
|
111
|
-
message(infoRequest: req.to_message)
|
112
|
-
end
|
82
|
+
res = call(:info, infoRequest: req.to_message)
|
113
83
|
InfoResponse.from_message(res.body[:infoResponse][:return])
|
114
|
-
rescue Savon::SOAPFault => e
|
115
|
-
# Extract bad request errors
|
116
|
-
maybe_raise_invalid_fields(e.to_hash[:Fault])
|
117
|
-
# Fallback to standard errro
|
118
|
-
raise StandardError, e.to_hash.dig(:Fault, :faultstring)
|
119
84
|
end
|
120
85
|
|
121
86
|
# Verifies the given MTAN.
|
@@ -123,15 +88,8 @@ module Zaala::API
|
|
123
88
|
ensure_operation_exists(:verify)
|
124
89
|
raise BadRequestError.new("info operation requires a VerifyRequest parameter") unless req.is_a?(VerifyRequest)
|
125
90
|
|
126
|
-
res =
|
127
|
-
message(verifyRequest: req.to_message)
|
128
|
-
end
|
91
|
+
res = call(:verify, verifyRequest: req.to_message)
|
129
92
|
VerifyResponse.from_message(res.body[:verifyResponse][:return])
|
130
|
-
rescue Savon::SOAPFault => e
|
131
|
-
# Extract bad request errors
|
132
|
-
maybe_raise_invalid_fields(e.to_hash[:Fault])
|
133
|
-
# Fallback to standard errro
|
134
|
-
raise StandardError, e.to_hash.dig(:Fault, :faultstring)
|
135
93
|
end
|
136
94
|
|
137
95
|
# Submits a purchase transaction with a previous authorization of funds.
|
@@ -139,15 +97,8 @@ module Zaala::API
|
|
139
97
|
ensure_operation_exists(:submit_authorization)
|
140
98
|
raise BadRequestError.new("info operation requires a SubmissionRequest parameter") unless req.is_a?(SubmissionRequest)
|
141
99
|
|
142
|
-
res =
|
143
|
-
message(submissionRequest: req.to_message)
|
144
|
-
end
|
100
|
+
res = call(:submit_authorization, submissionRequest: req.to_message)
|
145
101
|
SubmissionResponse.from_message(res.body[:submitAuthorizationResponse][:return])
|
146
|
-
rescue Savon::SOAPFault => e
|
147
|
-
# Extract bad request errors
|
148
|
-
maybe_raise_invalid_fields(e.to_hash[:Fault])
|
149
|
-
# Fallback to standard errro
|
150
|
-
raise StandardError, e.to_hash.dig(:Fault, :faultstring)
|
151
102
|
end
|
152
103
|
|
153
104
|
# Authorizes a credit transaction.
|
@@ -158,6 +109,24 @@ module Zaala::API
|
|
158
109
|
|
159
110
|
private
|
160
111
|
|
112
|
+
def call(request, attributes)
|
113
|
+
@kar.call(request) do
|
114
|
+
message(attributes)
|
115
|
+
end
|
116
|
+
rescue Savon::SOAPFault => e
|
117
|
+
# Extract permission errors
|
118
|
+
maybe_raise_authentication_error(e.to_hash[:Fault])
|
119
|
+
# Extract bad request errors
|
120
|
+
maybe_raise_invalid_fields(e.to_hash[:Fault])
|
121
|
+
# Fallback to standard errors
|
122
|
+
raise StandardError, e.to_hash.dig(:Fault, :faultstring)
|
123
|
+
end
|
124
|
+
|
125
|
+
def maybe_raise_authentication_error(fault)
|
126
|
+
code = fault.dig(:detail, :serverFaultMessage, :code)
|
127
|
+
raise PermissionError.new(fault[:faultstring]) if code == 'IS0003'
|
128
|
+
end
|
129
|
+
|
161
130
|
def maybe_raise_invalid_fields(fault)
|
162
131
|
fields = fault.dig(:detail, :invalidFieldsFaultMessage, :invalidFields)
|
163
132
|
fields = [fields] if fields.kind_of?(Hash)
|
data/lib/zaala/api/types.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zaala
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denteo AG
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-types
|