onlinepayments-sdk-ruby 8.2.0 → 8.2.1
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/onlinepayments/sdk/communication/metadata_provider.rb +1 -1
- data/lib/onlinepayments/sdk/communication/not_found_exception.rb +1 -1
- data/lib/onlinepayments/sdk/communication/response_exception.rb +2 -5
- data/lib/onlinepayments/sdk/communication/response_header.rb +5 -5
- data/lib/onlinepayments/sdk/communicator.rb +4 -4
- data/lib/onlinepayments/sdk/domain/uploadable_file.rb +2 -2
- data/lib/onlinepayments/sdk/exception_factory.rb +1 -0
- data/lib/onlinepayments/sdk/json/default_marshaller.rb +2 -5
- data/lib/onlinepayments/sdk/logging/request_log_message_builder.rb +2 -3
- data/lib/onlinepayments/sdk/webhooks/signature_validation_exception.rb +3 -1
- data/onlinepayments-sdk-ruby.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 378706048437fe7e8f9ea357cd95453cf63057a5552c5353c8df544a36bf9d7f
|
|
4
|
+
data.tar.gz: 6d7dbeb85ba5f49cdc6810f805dba3963520f7156195355744689ca7434f3f49
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8464617165ab9034463822c009b555bc9bcc1fa09dcc67f5c6e9edcff0ea8fd51a1b7380b6ebb0e466b01f503cb8718a7445a15dec4c459322cf1b6ba2fbe1d2
|
|
7
|
+
data.tar.gz: 30447d3611f81c1ed8dc20e8467761be89d7853cf45878ada4a8c2fb2f102b241bb5a0cb6f58c5d8f431db6134d4d98e7e978e14b7ddc508c861cba0802155bd
|
|
@@ -13,7 +13,7 @@ module OnlinePayments
|
|
|
13
13
|
class MetadataProvider
|
|
14
14
|
private
|
|
15
15
|
|
|
16
|
-
SDK_VERSION = '8.2.
|
|
16
|
+
SDK_VERSION = '8.2.1'.freeze
|
|
17
17
|
SERVER_META_INFO_HEADER = 'X-GCS-ServerMetaInfo'.freeze
|
|
18
18
|
PROHIBITED_HEADERS = [SERVER_META_INFO_HEADER, 'X-GCS-Idempotence-Key', 'Date', 'Content-Type', 'Authorization'].sort!.freeze
|
|
19
19
|
CHARSET = 'utf-8'.freeze
|
|
@@ -14,12 +14,9 @@ module OnlinePayments
|
|
|
14
14
|
super('the Online Payments platform returned an error response')
|
|
15
15
|
@status_code = status_code
|
|
16
16
|
@headers = if headers.nil? or headers.empty?
|
|
17
|
-
|
|
17
|
+
[]
|
|
18
18
|
else
|
|
19
|
-
headers.
|
|
20
|
-
hash[header.name.downcase.to_sym] = header.dup.freeze
|
|
21
|
-
hash
|
|
22
|
-
end
|
|
19
|
+
headers.map { |h| h.dup.freeze }
|
|
23
20
|
end.freeze
|
|
24
21
|
@body = body
|
|
25
22
|
end
|
|
@@ -51,8 +51,8 @@ module OnlinePayments
|
|
|
51
51
|
def self.get_disposition_filename(headers)
|
|
52
52
|
header_value = get_header_value(headers, "Content-Disposition")
|
|
53
53
|
unless header_value.nil?
|
|
54
|
-
if header_value =~ /(?:^|;)\s*filename\s*=\s*(.*?)\s*(?:;|$)i
|
|
55
|
-
return trim_quotes($
|
|
54
|
+
if header_value =~ /(?:^|;)\s*filename\s*=\s*(.*?)\s*(?:;|$)/i
|
|
55
|
+
return trim_quotes($1)
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
@@ -63,10 +63,10 @@ module OnlinePayments
|
|
|
63
63
|
|
|
64
64
|
# Trims the single or double quotes at the beginning and end of parameter _filename_ if they exist
|
|
65
65
|
# If they don't exist, it returns the original _filename_ instead
|
|
66
|
-
def trim_quotes(filename)
|
|
66
|
+
def self.trim_quotes(filename)
|
|
67
67
|
unless filename.length < 2
|
|
68
|
-
if (filename.chars.first == '\'' && filename.chars.last == '\
|
|
69
|
-
|
|
68
|
+
if (filename.chars.first == '\'' && filename.chars.last == '\'') ||
|
|
69
|
+
(filename.chars.first == '"' && filename.chars.last == '"')
|
|
70
70
|
return filename[1...-1]
|
|
71
71
|
end
|
|
72
72
|
end
|
|
@@ -42,12 +42,12 @@ module OnlinePayments
|
|
|
42
42
|
raise ArgumentError.new('connection is required') unless connection
|
|
43
43
|
raise ArgumentError.new('authenticator is required') unless authenticator
|
|
44
44
|
raise ArgumentError.new('metadata_provider is required') unless metadata_provider
|
|
45
|
-
raise ArgumentError('marshaller is required') if marshaller.nil?
|
|
45
|
+
raise ArgumentError.new('marshaller is required') if marshaller.nil?
|
|
46
46
|
|
|
47
47
|
uri = URI(api_endpoint)
|
|
48
|
-
raise RuntimeError('api_endpoint should not contain a path') unless uri.path.nil? || uri.path.empty?
|
|
48
|
+
raise RuntimeError.new('api_endpoint should not contain a path') unless uri.path.nil? || uri.path.empty?
|
|
49
49
|
unless uri.userinfo.nil? && uri.query.nil? && uri.fragment.nil?
|
|
50
|
-
raise RuntimeError('api_endpoint should not contain user info, query or fragment')
|
|
50
|
+
raise RuntimeError.new('api_endpoint should not contain user info, query or fragment')
|
|
51
51
|
end
|
|
52
52
|
@api_endpoint = uri
|
|
53
53
|
@connection = connection
|
|
@@ -499,7 +499,7 @@ module OnlinePayments
|
|
|
499
499
|
|
|
500
500
|
def throw_exception_if_necessary(body, status_code, headers, request_path)
|
|
501
501
|
if status_code < 200 || status_code >= 300
|
|
502
|
-
if !body.nil? && !is_json(headers)
|
|
502
|
+
if !body.nil? && !body.empty? && !is_json(headers)
|
|
503
503
|
cause = Communication::ResponseException.new(status_code, headers, body)
|
|
504
504
|
if status_code == 404
|
|
505
505
|
raise Communication::NotFoundException.new(cause, 'The requested resource was not found; invalid path: ' +
|
|
@@ -13,9 +13,9 @@ module OnlinePayments
|
|
|
13
13
|
class UploadableFile
|
|
14
14
|
|
|
15
15
|
def initialize(file_name, content, content_type, content_length = -1)
|
|
16
|
-
raise ArgumentError.new("file_name is required") if file_name.nil?
|
|
16
|
+
raise ArgumentError.new("file_name is required") if file_name.nil? || file_name.strip.empty?
|
|
17
17
|
raise ArgumentError.new("content is required") if content.nil?
|
|
18
|
-
raise ArgumentError.new("content_type is required") if content_type.nil?
|
|
18
|
+
raise ArgumentError.new("content_type is required") if content_type.nil? || content_type.strip.empty?
|
|
19
19
|
|
|
20
20
|
@file_name = file_name
|
|
21
21
|
@content = content
|
|
@@ -36,6 +36,7 @@ module OnlinePayments
|
|
|
36
36
|
if error_object.is_a?(OnlinePayments::SDK::Domain::ProblemDetailsResponse)
|
|
37
37
|
return ProblemDetailsException.new(status_code, response_body, error_object)
|
|
38
38
|
end
|
|
39
|
+
return ApiException.new(status_code, response_body, nil, nil) if error_object.nil?
|
|
39
40
|
raise ArgumentError.new("unsupported error object type: " + error_object.class.name) unless error_object.is_a?(OnlinePayments::SDK::Domain::ErrorResponse)
|
|
40
41
|
create_exception_from_response_fields(status_code, response_body, error_object.error_id, error_object.errors, context)
|
|
41
42
|
end
|
|
@@ -12,16 +12,13 @@ module OnlinePayments
|
|
|
12
12
|
|
|
13
13
|
# Marshals the _request_object_ to a JSON string using request_object#to_h
|
|
14
14
|
def marshal(request_object)
|
|
15
|
+
return 'null' if request_object.nil?
|
|
15
16
|
::JSON.pretty_generate(request_object.to_h)
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
# Unmarshals a JSON string into an object of type _klass_ using klass.new_from_hash
|
|
19
20
|
def unmarshal(json_string, klass)
|
|
20
|
-
if json_string.nil?
|
|
21
|
-
return nil
|
|
22
|
-
elsif json_string.length == 0
|
|
23
|
-
return ''
|
|
24
|
-
end
|
|
21
|
+
return nil if json_string.nil? || json_string.empty?
|
|
25
22
|
if klass.respond_to?(:new_from_hash)
|
|
26
23
|
klass.new_from_hash(::JSON.load(json_string))
|
|
27
24
|
else
|
|
@@ -36,13 +36,12 @@ module OnlinePayments
|
|
|
36
36
|
private
|
|
37
37
|
|
|
38
38
|
def format_uri
|
|
39
|
-
'' unless @uri && @uri.path
|
|
39
|
+
return '' unless @uri && @uri.path
|
|
40
40
|
if @uri.query.nil?
|
|
41
41
|
@uri.path
|
|
42
42
|
else
|
|
43
|
-
"#{@uri.path}?#{@uri.query}"
|
|
43
|
+
"#{@uri.path}?#{@uri.query}"
|
|
44
44
|
end
|
|
45
|
-
# @uri.path + '?' + empty_if_null(@uri.query)
|
|
46
45
|
end
|
|
47
46
|
end
|
|
48
47
|
end
|
|
@@ -10,7 +10,9 @@ module OnlinePayments
|
|
|
10
10
|
# @option args [String] :message the error message
|
|
11
11
|
# @option args [RuntimeError] :cause an Error object that causes the Exception
|
|
12
12
|
def initialize(args)
|
|
13
|
-
|
|
13
|
+
msg = args[:message]
|
|
14
|
+
msg = args[:cause].to_s if msg.nil? && !args[:cause].nil?
|
|
15
|
+
super(msg)
|
|
14
16
|
# store backtrace info if exception given
|
|
15
17
|
set_backtrace(args[:cause].backtrace) unless args[:cause].nil?
|
|
16
18
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |spec|
|
|
2
2
|
spec.name = 'onlinepayments-sdk-ruby'
|
|
3
|
-
spec.version = '8.2.
|
|
3
|
+
spec.version = '8.2.1'
|
|
4
4
|
spec.authors = ['Worldline Direct support team']
|
|
5
5
|
spec.email = ['82139942+worldline-direct-support-team@users.noreply.github.com']
|
|
6
6
|
spec.summary = %q{SDK to communicate with the Online Payments platform using the Online Payments Server API}
|