zaala 0.1.0 → 0.2.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 +49 -26
- data/lib/zaala/api/error.rb +14 -0
- data/lib/zaala/api/types.rb +48 -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: 3e7ce8d64c7b4f13fb5c03dfc38a431595842dd4d4d34d7c3444014ca458976a
|
4
|
+
data.tar.gz: 8d1bcb796c6b71649bfe92fb8a46fc8c42657ad24fbbe1ceea457301c6977dc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df99053a8a416b55b7fb4967ae021ce1315257d7123b3a72b8547c1e4cfd72e668c40983701ed014c17d0377b7428ea5237e9d0eb71512d51a3088e21afdefe1
|
7
|
+
data.tar.gz: db5b6b6d59c76d4fdfcec8e0ecd995db275fa70c243e3424bb0c07eb9093c54699af2cf464643e3307d6a974b96f5fc21e6193a053ac220c35ad036c08315c43
|
data/lib/zaala/api/client.rb
CHANGED
@@ -13,8 +13,8 @@ module Zaala::API
|
|
13
13
|
symbolize_keys = lambda { |key| key.to_sym }
|
14
14
|
params = {
|
15
15
|
wsdl: wsdl,
|
16
|
-
open_timeout: 30, #
|
17
|
-
read_timeout: 30, #
|
16
|
+
open_timeout: 30, # seconds
|
17
|
+
read_timeout: 30, # seconds
|
18
18
|
convert_response_tags_to: symbolize_keys,
|
19
19
|
log: log,
|
20
20
|
proxy: proxy
|
@@ -43,14 +43,15 @@ 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
|
-
@kar.call(:pre_authorize) do
|
46
|
+
res = @kar.call(:pre_authorize) do
|
47
47
|
message(authorizationRequest: req.to_message)
|
48
48
|
end
|
49
|
+
AuthorizationResponse.from_message(res.body[:preAuthorizeResponse][:return])
|
49
50
|
rescue Savon::SOAPFault => e
|
50
|
-
#
|
51
|
-
|
52
|
-
#
|
53
|
-
raise
|
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)
|
54
55
|
end
|
55
56
|
|
56
57
|
# Authorizes a purchase transaction.
|
@@ -63,8 +64,10 @@ module Zaala::API
|
|
63
64
|
end
|
64
65
|
AuthorizationResponse.from_message(res.body[:authorizeResponse][:return])
|
65
66
|
rescue Savon::SOAPFault => e
|
66
|
-
#
|
67
|
-
|
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)
|
68
71
|
end
|
69
72
|
|
70
73
|
# Cancel a previous reservation of funds.
|
@@ -72,12 +75,15 @@ module Zaala::API
|
|
72
75
|
ensure_operation_exists(:cancel_authorization)
|
73
76
|
raise BadRequestError.new("cancel_authorization operation requires a CancellationRequest parameter") unless req.is_a?(CancellationRequest)
|
74
77
|
|
75
|
-
@kar.call(:cancel_authorization) do
|
78
|
+
res = @kar.call(:cancel_authorization) do
|
76
79
|
message(cancellationRequest: req.to_message)
|
77
80
|
end
|
81
|
+
CancellationResponse.from_message(res.body[:cancelAuthorizationResponse][:return])
|
78
82
|
rescue Savon::SOAPFault => e
|
79
|
-
#
|
80
|
-
|
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)
|
81
87
|
end
|
82
88
|
|
83
89
|
# Perform a solvency check.
|
@@ -85,12 +91,15 @@ module Zaala::API
|
|
85
91
|
ensure_operation_exists(:check)
|
86
92
|
raise BadRequestError.new("check operation requires a CheckRequest parameter") unless req.is_a?(CheckRequest)
|
87
93
|
|
88
|
-
@kar.call(:check) do
|
94
|
+
res = @kar.call(:check) do
|
89
95
|
message(checkRequest: req.to_message)
|
90
96
|
end
|
97
|
+
CheckResponse.from_message(res.body[:checkResponse][:return])
|
91
98
|
rescue Savon::SOAPFault => e
|
92
|
-
#
|
93
|
-
|
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)
|
94
103
|
end
|
95
104
|
|
96
105
|
# Returns available information about an authorization-ID.
|
@@ -98,13 +107,15 @@ module Zaala::API
|
|
98
107
|
ensure_operation_exists(:info)
|
99
108
|
raise BadRequestError.new("info operation requires an InfoRequest parameter") unless req.is_a?(InfoRequest)
|
100
109
|
|
101
|
-
@kar.call(:info) do
|
110
|
+
res = @kar.call(:info) do
|
102
111
|
message(infoRequest: req.to_message)
|
103
112
|
end
|
113
|
+
InfoResponse.from_message(res.body[:infoResponse][:return])
|
104
114
|
rescue Savon::SOAPFault => e
|
105
|
-
#
|
106
|
-
|
107
|
-
|
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)
|
108
119
|
end
|
109
120
|
|
110
121
|
# Verifies the given MTAN.
|
@@ -112,13 +123,15 @@ module Zaala::API
|
|
112
123
|
ensure_operation_exists(:verify)
|
113
124
|
raise BadRequestError.new("info operation requires a VerifyRequest parameter") unless req.is_a?(VerifyRequest)
|
114
125
|
|
115
|
-
@kar.call(:verify) do
|
126
|
+
res = @kar.call(:verify) do
|
116
127
|
message(verifyRequest: req.to_message)
|
117
128
|
end
|
129
|
+
VerifyResponse.from_message(res.body[:verifyResponse][:return])
|
118
130
|
rescue Savon::SOAPFault => e
|
119
|
-
#
|
120
|
-
|
121
|
-
|
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)
|
122
135
|
end
|
123
136
|
|
124
137
|
# Submits a purchase transaction with a previous authorization of funds.
|
@@ -131,9 +144,10 @@ module Zaala::API
|
|
131
144
|
end
|
132
145
|
SubmissionResponse.from_message(res.body[:submitAuthorizationResponse][:return])
|
133
146
|
rescue Savon::SOAPFault => e
|
134
|
-
#
|
135
|
-
|
136
|
-
|
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)
|
137
151
|
end
|
138
152
|
|
139
153
|
# Authorizes a credit transaction.
|
@@ -144,6 +158,15 @@ module Zaala::API
|
|
144
158
|
|
145
159
|
private
|
146
160
|
|
161
|
+
def maybe_raise_invalid_fields(fault)
|
162
|
+
fields = fault.dig(:detail, :invalidFieldsFaultMessage, :invalidFields)
|
163
|
+
fields = [fields] if fields.kind_of?(Hash)
|
164
|
+
return [] unless fields.kind_of?(Array)
|
165
|
+
|
166
|
+
fields = fields.map { |f| FieldViolation.new(f[:code], f[:message]) }
|
167
|
+
raise BadRequestError.new(fault[:faultstring], fields) unless fields.empty?
|
168
|
+
end
|
169
|
+
|
147
170
|
def ensure_operation_exists(op)
|
148
171
|
raise(UnsupportedServiceEndpoint, op) unless @kar.operations.include?(op)
|
149
172
|
end
|
data/lib/zaala/api/error.rb
CHANGED
@@ -1,7 +1,21 @@
|
|
1
1
|
module Zaala::API
|
2
2
|
class MissingError < StandardError
|
3
3
|
end
|
4
|
+
class FieldViolation
|
5
|
+
attr_reader :field, :description
|
6
|
+
|
7
|
+
def initialize(field, description)
|
8
|
+
@field = field
|
9
|
+
@description = description
|
10
|
+
end
|
11
|
+
end
|
4
12
|
class BadRequestError < StandardError
|
13
|
+
attr_reader :fields
|
14
|
+
|
15
|
+
def initialize(msg, fields = [])
|
16
|
+
super(msg)
|
17
|
+
@fields = fields
|
18
|
+
end
|
5
19
|
end
|
6
20
|
class PermissionError < StandardError
|
7
21
|
end
|
data/lib/zaala/api/types.rb
CHANGED
@@ -804,7 +804,7 @@ module Zaala::API
|
|
804
804
|
{
|
805
805
|
identifier: identifier.to_message,
|
806
806
|
additionalData: additional_data.to_message,
|
807
|
-
verificationCode: verification_code
|
807
|
+
verificationCode: verification_code
|
808
808
|
}
|
809
809
|
end
|
810
810
|
end
|
@@ -830,4 +830,51 @@ module Zaala::API
|
|
830
830
|
})
|
831
831
|
end
|
832
832
|
end
|
833
|
+
|
834
|
+
class CheckRequest < Dry::Struct
|
835
|
+
# Environment parameters and information to identify the caller.
|
836
|
+
attribute :identifier, Zaala::API::RequestIdentifier
|
837
|
+
# Personal data of the customer.
|
838
|
+
attribute :personal_data, Zaala::API::PersonalData
|
839
|
+
# Invoice address of the purchase.
|
840
|
+
attribute :invoice_address, Zaala::API::InvoiceAddress
|
841
|
+
# Key-value pairs holding information of the service's client (e.g. IPv4 address).
|
842
|
+
# attribute :client_info, Zaala::API::ClientInfo
|
843
|
+
# Requested amount of the preauthorization/authorization.
|
844
|
+
# It corresponds to the total amount, which has to be authorized.
|
845
|
+
# Mandatory if no Basket is provided in the request.
|
846
|
+
# (IF0001) If a Basket is provided in the request, this value is ignored.
|
847
|
+
attribute :requested_amount, Types::Strict::Float
|
848
|
+
# Additional purchase related information.
|
849
|
+
attribute :additional_data, Zaala::API::AdditionalData
|
850
|
+
|
851
|
+
def to_message
|
852
|
+
{
|
853
|
+
identifier: identifier.to_message,
|
854
|
+
personal_data: personal_data.to_message,
|
855
|
+
invoice_address: invoice_address.to_message,
|
856
|
+
client_info: client_info.to_message,
|
857
|
+
requested_amount: requested_amount,
|
858
|
+
additional_data: additional_data.to_message
|
859
|
+
}
|
860
|
+
end
|
861
|
+
end
|
862
|
+
|
863
|
+
class CheckResponse < Dry::Struct
|
864
|
+
# Contains information to identify the authorization in a future request.
|
865
|
+
attribute :identifier, Zaala::API::ResponseIdentifier
|
866
|
+
# Contains additional information concerning the authorization.
|
867
|
+
attribute :decision, Zaala::API::Decision
|
868
|
+
|
869
|
+
# Contains additional information concerning the authorization.
|
870
|
+
attribute :info, Zaala::API::Info.optional.default(nil)
|
871
|
+
|
872
|
+
def self.from_message(h)
|
873
|
+
VerifyResponse.new({
|
874
|
+
identifier: Zaala::API::ResponseIdentifier.from_message(h[:identifier]),
|
875
|
+
decision: Zaala::API::Decision.from_message(h[:decision]),
|
876
|
+
info: h[:info] ? Zaala::API::Info.from_message(h[:info]) : nil,
|
877
|
+
})
|
878
|
+
end
|
879
|
+
end
|
833
880
|
end
|
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.2.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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-types
|