zaala 0.1.0 → 0.4.2
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/lib/zaala/api/client.rb +41 -49
- data/lib/zaala/api/error.rb +14 -0
- data/lib/zaala/api/types.rb +50 -7
- metadata +12 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e4509ce6426dfdc533917459dfe74aaf5188c04c0de9ba8d6179871a44e1e29c
|
|
4
|
+
data.tar.gz: f4e4c1a148ef03541b42bd721c11d270749fcd632b53397f3b91d1fb240395b7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3f214835a9a492b5fc289b7d547ea8324ab637e31b3f845afc380328a6db01af22afb37d3bcd461b0ae8c836acd97117ae220c83074f662ae67561925d02e1db
|
|
7
|
+
data.tar.gz: 79083f534a65c849311cf8e96a0ed2bc89ca5df09b8511240fd9df0de8a0d15a751f9fbe56b1f79596100533d538eb6dfa0f6a4f4738c0a4af49d4dd358a28c2
|
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,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
|
-
|
|
47
|
-
|
|
48
|
-
end
|
|
49
|
-
rescue Savon::SOAPFault => e
|
|
50
|
-
# IS0003
|
|
51
|
-
# TODO: Extract error code from response body
|
|
52
|
-
# e.g. (The content of at least one field is invalid and did not pass the validation)
|
|
53
|
-
raise BadRequestError.new(e)
|
|
46
|
+
res = call(:pre_authorize, authorizationRequest: req.to_message)
|
|
47
|
+
AuthorizationResponse.from_message(res.body[:preAuthorizeResponse][:return])
|
|
54
48
|
end
|
|
55
49
|
|
|
56
50
|
# Authorizes a purchase transaction.
|
|
@@ -58,13 +52,8 @@ module Zaala::API
|
|
|
58
52
|
ensure_operation_exists(:authorize)
|
|
59
53
|
raise BadRequestError.new("authorize operation requires an AuthorizationRequest parameter") unless req.is_a?(AuthorizationRequest)
|
|
60
54
|
|
|
61
|
-
res =
|
|
62
|
-
message(authorizationRequest: req.to_message)
|
|
63
|
-
end
|
|
55
|
+
res = call(:authorize, authorizationRequest: req.to_message)
|
|
64
56
|
AuthorizationResponse.from_message(res.body[:authorizeResponse][:return])
|
|
65
|
-
rescue Savon::SOAPFault => e
|
|
66
|
-
# e.g. (The content of at least one field is invalid and did not pass the validation)
|
|
67
|
-
raise BadRequestError.new(e)
|
|
68
57
|
end
|
|
69
58
|
|
|
70
59
|
# Cancel a previous reservation of funds.
|
|
@@ -72,12 +61,8 @@ module Zaala::API
|
|
|
72
61
|
ensure_operation_exists(:cancel_authorization)
|
|
73
62
|
raise BadRequestError.new("cancel_authorization operation requires a CancellationRequest parameter") unless req.is_a?(CancellationRequest)
|
|
74
63
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
end
|
|
78
|
-
rescue Savon::SOAPFault => e
|
|
79
|
-
# e.g. (The content of at least one field is invalid and did not pass the validation)
|
|
80
|
-
raise BadRequestError.new(e)
|
|
64
|
+
res = call(:cancel_authorization, cancellationRequest: req.to_message)
|
|
65
|
+
CancellationResponse.from_message(res.body[:cancelAuthorizationResponse][:return])
|
|
81
66
|
end
|
|
82
67
|
|
|
83
68
|
# Perform a solvency check.
|
|
@@ -85,12 +70,8 @@ module Zaala::API
|
|
|
85
70
|
ensure_operation_exists(:check)
|
|
86
71
|
raise BadRequestError.new("check operation requires a CheckRequest parameter") unless req.is_a?(CheckRequest)
|
|
87
72
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
end
|
|
91
|
-
rescue Savon::SOAPFault => e
|
|
92
|
-
# e.g. (The content of at least one field is invalid and did not pass the validation)
|
|
93
|
-
raise BadRequestError.new(e)
|
|
73
|
+
res = call(:check, checkRequest: req.to_message)
|
|
74
|
+
CheckResponse.from_message(res.body[:checkResponse][:return])
|
|
94
75
|
end
|
|
95
76
|
|
|
96
77
|
# Returns available information about an authorization-ID.
|
|
@@ -98,13 +79,8 @@ module Zaala::API
|
|
|
98
79
|
ensure_operation_exists(:info)
|
|
99
80
|
raise BadRequestError.new("info operation requires an InfoRequest parameter") unless req.is_a?(InfoRequest)
|
|
100
81
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
end
|
|
104
|
-
rescue Savon::SOAPFault => e
|
|
105
|
-
# TODO: Extract error code from response body
|
|
106
|
-
# e.g. (The content of at least one field is invalid and did not pass the validation)
|
|
107
|
-
raise BadRequestError.new(e)
|
|
82
|
+
res = call(:info, infoRequest: req.to_message)
|
|
83
|
+
InfoResponse.from_message(res.body[:infoResponse][:return])
|
|
108
84
|
end
|
|
109
85
|
|
|
110
86
|
# Verifies the given MTAN.
|
|
@@ -112,13 +88,8 @@ module Zaala::API
|
|
|
112
88
|
ensure_operation_exists(:verify)
|
|
113
89
|
raise BadRequestError.new("info operation requires a VerifyRequest parameter") unless req.is_a?(VerifyRequest)
|
|
114
90
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
end
|
|
118
|
-
rescue Savon::SOAPFault => e
|
|
119
|
-
# TODO: Extract error code from response body
|
|
120
|
-
# e.g. (The content of at least one field is invalid and did not pass the validation)
|
|
121
|
-
raise BadRequestError.new(e)
|
|
91
|
+
res = call(:verify, verifyRequest: req.to_message)
|
|
92
|
+
VerifyResponse.from_message(res.body[:verifyResponse][:return])
|
|
122
93
|
end
|
|
123
94
|
|
|
124
95
|
# Submits a purchase transaction with a previous authorization of funds.
|
|
@@ -126,14 +97,8 @@ module Zaala::API
|
|
|
126
97
|
ensure_operation_exists(:submit_authorization)
|
|
127
98
|
raise BadRequestError.new("info operation requires a SubmissionRequest parameter") unless req.is_a?(SubmissionRequest)
|
|
128
99
|
|
|
129
|
-
res =
|
|
130
|
-
message(submissionRequest: req.to_message)
|
|
131
|
-
end
|
|
100
|
+
res = call(:submit_authorization, submissionRequest: req.to_message)
|
|
132
101
|
SubmissionResponse.from_message(res.body[:submitAuthorizationResponse][:return])
|
|
133
|
-
rescue Savon::SOAPFault => e
|
|
134
|
-
# TODO: Extract error code from response body
|
|
135
|
-
# e.g. (The content of at least one field is invalid and did not pass the validation)
|
|
136
|
-
raise BadRequestError.new(e)
|
|
137
102
|
end
|
|
138
103
|
|
|
139
104
|
# Authorizes a credit transaction.
|
|
@@ -144,6 +109,33 @@ module Zaala::API
|
|
|
144
109
|
|
|
145
110
|
private
|
|
146
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
|
+
|
|
130
|
+
def maybe_raise_invalid_fields(fault)
|
|
131
|
+
fields = fault.dig(:detail, :invalidFieldsFaultMessage, :invalidFields)
|
|
132
|
+
fields = [fields] if fields.kind_of?(Hash)
|
|
133
|
+
return [] unless fields.kind_of?(Array)
|
|
134
|
+
|
|
135
|
+
fields = fields.map { |f| FieldViolation.new(f[:code], f[:message]) }
|
|
136
|
+
raise BadRequestError.new(fault[:faultstring], fields) unless fields.empty?
|
|
137
|
+
end
|
|
138
|
+
|
|
147
139
|
def ensure_operation_exists(op)
|
|
148
140
|
raise(UnsupportedServiceEndpoint, op) unless @kar.operations.include?(op)
|
|
149
141
|
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
|
@@ -470,9 +470,6 @@ module Zaala::API
|
|
|
470
470
|
# The content of the attachment (base64 encoded).
|
|
471
471
|
attribute :value, Types::Strict::String
|
|
472
472
|
|
|
473
|
-
def from_file
|
|
474
|
-
end
|
|
475
|
-
|
|
476
473
|
def self.from_message(h)
|
|
477
474
|
Attachment.new({
|
|
478
475
|
name: h[:name],
|
|
@@ -483,8 +480,8 @@ module Zaala::API
|
|
|
483
480
|
|
|
484
481
|
def to_message
|
|
485
482
|
{
|
|
486
|
-
name
|
|
487
|
-
mimeType
|
|
483
|
+
:@name => name,
|
|
484
|
+
:@mimeType => mime_type,
|
|
488
485
|
value: value
|
|
489
486
|
}
|
|
490
487
|
end
|
|
@@ -695,7 +692,7 @@ module Zaala::API
|
|
|
695
692
|
identifier: identifier.to_message,
|
|
696
693
|
basket: basket.to_message,
|
|
697
694
|
additionalData: additional_data.to_message,
|
|
698
|
-
|
|
695
|
+
attachment: attachments.map(&:to_message),
|
|
699
696
|
}
|
|
700
697
|
end
|
|
701
698
|
end
|
|
@@ -804,7 +801,7 @@ module Zaala::API
|
|
|
804
801
|
{
|
|
805
802
|
identifier: identifier.to_message,
|
|
806
803
|
additionalData: additional_data.to_message,
|
|
807
|
-
verificationCode: verification_code
|
|
804
|
+
verificationCode: verification_code
|
|
808
805
|
}
|
|
809
806
|
end
|
|
810
807
|
end
|
|
@@ -830,4 +827,50 @@ module Zaala::API
|
|
|
830
827
|
})
|
|
831
828
|
end
|
|
832
829
|
end
|
|
830
|
+
|
|
831
|
+
class CheckRequest < Dry::Struct
|
|
832
|
+
# Environment parameters and information to identify the caller.
|
|
833
|
+
attribute :identifier, Zaala::API::RequestIdentifier
|
|
834
|
+
# Personal data of the customer.
|
|
835
|
+
attribute :personal_data, Zaala::API::PersonalData
|
|
836
|
+
# Invoice address of the purchase.
|
|
837
|
+
attribute :invoice_address, Zaala::API::InvoiceAddress
|
|
838
|
+
# Key-value pairs holding information of the service's client (e.g. IPv4 address).
|
|
839
|
+
# attribute :client_info, Zaala::API::ClientInfo
|
|
840
|
+
# Requested amount of the preauthorization/authorization.
|
|
841
|
+
# It corresponds to the total amount, which has to be authorized.
|
|
842
|
+
# Mandatory if no Basket is provided in the request.
|
|
843
|
+
# (IF0001) If a Basket is provided in the request, this value is ignored.
|
|
844
|
+
attribute :requested_amount, Types::Strict::Float
|
|
845
|
+
# Additional purchase related information.
|
|
846
|
+
attribute :additional_data, Zaala::API::AdditionalData
|
|
847
|
+
|
|
848
|
+
def to_message
|
|
849
|
+
{
|
|
850
|
+
identifier: identifier.to_message,
|
|
851
|
+
personal_data: personal_data.to_message,
|
|
852
|
+
invoice_address: invoice_address.to_message,
|
|
853
|
+
requested_amount: requested_amount,
|
|
854
|
+
additional_data: additional_data.to_message
|
|
855
|
+
}
|
|
856
|
+
end
|
|
857
|
+
end
|
|
858
|
+
|
|
859
|
+
class CheckResponse < Dry::Struct
|
|
860
|
+
# Contains information to identify the authorization in a future request.
|
|
861
|
+
attribute :identifier, Zaala::API::ResponseIdentifier
|
|
862
|
+
# Contains additional information concerning the authorization.
|
|
863
|
+
attribute :decision, Zaala::API::Decision
|
|
864
|
+
|
|
865
|
+
# Contains additional information concerning the authorization.
|
|
866
|
+
attribute :info, Zaala::API::Info.optional.default(nil)
|
|
867
|
+
|
|
868
|
+
def self.from_message(h)
|
|
869
|
+
VerifyResponse.new({
|
|
870
|
+
identifier: Zaala::API::ResponseIdentifier.from_message(h[:identifier]),
|
|
871
|
+
decision: Zaala::API::Decision.from_message(h[:decision]),
|
|
872
|
+
info: h[:info] ? Zaala::API::Info.from_message(h[:info]) : nil,
|
|
873
|
+
})
|
|
874
|
+
end
|
|
875
|
+
end
|
|
833
876
|
end
|
metadata
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zaala
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Denteo AG
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-03-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: dry-
|
|
14
|
+
name: dry-struct
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - '='
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 1.
|
|
19
|
+
version: 1.6.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - '='
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 1.
|
|
26
|
+
version: 1.6.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: dry-
|
|
28
|
+
name: dry-types
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - '='
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 1.
|
|
33
|
+
version: 1.7.1
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - '='
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 1.
|
|
40
|
+
version: 1.7.1
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: savon
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -67,7 +67,7 @@ homepage: https://rubygems.org/gems/zaala
|
|
|
67
67
|
licenses:
|
|
68
68
|
- MIT
|
|
69
69
|
metadata: {}
|
|
70
|
-
post_install_message:
|
|
70
|
+
post_install_message:
|
|
71
71
|
rdoc_options: []
|
|
72
72
|
require_paths:
|
|
73
73
|
- lib
|
|
@@ -82,8 +82,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
82
82
|
- !ruby/object:Gem::Version
|
|
83
83
|
version: '0'
|
|
84
84
|
requirements: []
|
|
85
|
-
rubygems_version: 3.
|
|
86
|
-
signing_key:
|
|
85
|
+
rubygems_version: 3.4.10
|
|
86
|
+
signing_key:
|
|
87
87
|
specification_version: 4
|
|
88
88
|
summary: Ruby client interacting with Zaala
|
|
89
89
|
test_files: []
|