connect-sdk-ruby 5.0.0 → 5.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f1cb58509ee13a6f901b29e5da28837958cfcb1d574b3ebee1b908d654a89bb
4
- data.tar.gz: d063c020e3995486220c4d72303905b98b0b6ef3c5eb6cbed9392d86798f6628
3
+ metadata.gz: 58cbad6e878461552ac4206cf9951c00a9dcaf15224b58b75e8296217f6aba0c
4
+ data.tar.gz: 5669d32653bf1f26c277c873e60452bb4862e7e52cd0a94777bd1e9a45e0a06c
5
5
  SHA512:
6
- metadata.gz: c3d49a2225746da3328bc7f544510d3f652981ae3606a46a94102ed6a51577ce7ba0abc7429e43dc9654fcbd08c52f1f9180ba85b595a178df95cc90f3297d7d
7
- data.tar.gz: 8243a73cc4b957b860a04863e28f8093ae252e8ab029216d86ce4458c940184dc66a1239a9cd99eb57888a4d0bb8d4a4ab2902bcb1fe3c509be7a1685f08531e
6
+ metadata.gz: 0ffbd46cde3450c1b117ecadfbf6f63ca22a693b1d6f01f08b0c5ecf5a28a7e1de06284306f5e1bd9266be7734e3ed090d029bddee5091ca6ee18c5d0cf78d32
7
+ data.tar.gz: 6a98c7656ea0a68938d7b1490cb956ae892939f7507a90da316802fbb1ec47026b07f1b85dec58ce339cae2cf1554f8b724196904824b93ed3fb46c63b49b226
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'connect-sdk-ruby'
3
- spec.version = '5.0.0'
3
+ spec.version = '5.0.1'
4
4
  spec.authors = ['Worldline Global Collect']
5
5
  spec.email = ['github.connect@worldline.com']
6
6
  spec.summary = %q{SDK to communicate with the Worldline Global Collect platform using the Worldline Connect Server API}
@@ -14,7 +14,7 @@ module Worldline
14
14
  class MetadataProvider
15
15
  private
16
16
 
17
- SDK_VERSION = '5.0.0'.freeze
17
+ SDK_VERSION = '5.0.1'.freeze
18
18
  SERVER_META_INFO_HEADER = 'X-GCS-ServerMetaInfo'.freeze
19
19
  PROHIBITED_HEADERS = [SERVER_META_INFO_HEADER, 'X-GCS-Idempotence-Key','Date', 'Content-Type', 'Authorization'].sort!.freeze
20
20
  CHARSET = 'utf-8'.freeze
@@ -15,12 +15,9 @@ module Worldline
15
15
  super('the Worldline Global Collect platform returned an error response')
16
16
  @status_code = status_code
17
17
  @headers = if headers.nil? or headers.empty?
18
- {}
18
+ []
19
19
  else
20
- headers.inject({}) do |hash, header|
21
- hash[header.name.downcase.to_sym] = header.dup.freeze
22
- hash
23
- end
20
+ headers.map { |h| h.dup.freeze }
24
21
  end.freeze
25
22
  @body = body
26
23
  end
@@ -51,8 +51,8 @@ module Worldline
51
51
  # If this Response does not contain a header with the given name, return _nil_ instead
52
52
  def self.get_disposition_filename(headers)
53
53
  header_value = get_header_value(headers, "Content-Disposition")
54
- if !header_value.nil? && header_value =~ /(?:^|;)\s*filename\s*=\s*(.*?)\s*(?:;|$)i/
55
- return trim_quotes($2)
54
+ if !header_value.nil? && header_value =~ /(?:^|;)\s*filename\s*=\s*(.*?)\s*(?:;|$)/i
55
+ return trim_quotes($1)
56
56
  end
57
57
 
58
58
  return nil
@@ -62,9 +62,9 @@ module Worldline
62
62
 
63
63
  # Trims the single or double quotes at the beginning and end of parameter _filename_ if they exist
64
64
  # If they don't exist, it returns the original _filename_ instead
65
- def trim_quotes(filename)
65
+ def self.trim_quotes(filename)
66
66
  if filename.length >= 2 &&
67
- (filename.chars.first == '\'' && filename.chars.last == '\'') || (filename.chars.first == '"' && filename.chars.last == '"')
67
+ ((filename.chars.first == '\'' && filename.chars.last == '\'') || (filename.chars.first == '"' && filename.chars.last == '"'))
68
68
  return filename[1...-1]
69
69
  end
70
70
  filename
@@ -41,12 +41,12 @@ module Worldline
41
41
  raise ArgumentError.new('connection is required') unless connection
42
42
  raise ArgumentError.new('authenticator is required') unless authenticator
43
43
  raise ArgumentError.new('metadata_provider is required') unless metadata_provider
44
- raise ArgumentError('marshaller is required') if marshaller.nil?
44
+ raise ArgumentError.new('marshaller is required') if marshaller.nil?
45
45
 
46
46
  uri = URI(api_endpoint)
47
- raise RuntimeError('api_endpoint should not contain a path') unless uri.path.nil? || uri.path.empty?
47
+ raise RuntimeError.new('api_endpoint should not contain a path') unless uri.path.nil? || uri.path.empty?
48
48
  unless uri.userinfo.nil? && uri.query.nil? && uri.fragment.nil?
49
- raise RuntimeError('api_endpoint should not contain user info, query or fragment')
49
+ raise RuntimeError.new('api_endpoint should not contain user info, query or fragment')
50
50
  end
51
51
  @api_endpoint = uri
52
52
  @connection = connection
@@ -483,7 +483,7 @@ module Worldline
483
483
 
484
484
  def throw_exception_if_necessary(body, status_code, headers, request_path)
485
485
  if status_code < 200 || status_code >= 300
486
- if !body.nil? && !is_json(headers)
486
+ if !body.nil? && !body.empty? && !is_json(headers)
487
487
  cause = Communication::ResponseException.new(status_code, headers, body)
488
488
  if status_code == 404
489
489
  raise Communication::NotFoundException.new(cause, 'The requested resource was not found; invalid path: ' +
@@ -14,9 +14,9 @@ module Worldline
14
14
  class UploadableFile
15
15
 
16
16
  def initialize(file_name, content, content_type, content_length = -1)
17
- raise ArgumentError.new("file_name is required") if file_name.nil? or !file_name.strip
17
+ raise ArgumentError.new("file_name is required") if file_name.nil? or file_name.strip.empty?
18
18
  raise ArgumentError.new("content is required") if content.nil?
19
- raise ArgumentError.new("content_type is required") if content_type.nil? or !content_type.strip
19
+ raise ArgumentError.new("content_type is required") if content_type.nil? or content_type.strip.empty?
20
20
 
21
21
  @file_name = file_name
22
22
  @content = content
@@ -13,15 +13,14 @@ module Worldline
13
13
 
14
14
  # Marshals the _request_object_ to a JSON string using request_object#to_h
15
15
  def marshal(request_object)
16
+ return 'null' if request_object.nil?
16
17
  ::JSON.pretty_generate(request_object.to_h)
17
18
  end
18
19
 
19
20
  # Unmarshals a JSON string into an object of type _klass_ using klass.new_from_hash
20
21
  def unmarshal(json_string, klass)
21
- if json_string.nil?
22
+ if json_string.nil? or json_string.empty?
22
23
  return nil
23
- elsif json_string.length == 0
24
- return ''
25
24
  end
26
25
  if klass.respond_to?(:new_from_hash)
27
26
  klass.new_from_hash(::JSON.load(json_string))
@@ -37,13 +37,12 @@ module Worldline
37
37
  private
38
38
 
39
39
  def format_uri
40
- '' unless @uri && @uri.path
40
+ return '' unless @uri && @uri.path
41
41
  if @uri.query.nil?
42
42
  @uri.path
43
43
  else
44
- "#{@uri.path}?#{@uri.query}" unless @uri.query.nil?
44
+ "#{@uri.path}?#{@uri.query}"
45
45
  end
46
- # @uri.path + '?' + empty_if_null(@uri.query)
47
46
  end
48
47
  end
49
48
  end
@@ -34,6 +34,7 @@ module Worldline
34
34
  return DeclinedRefundException.new(status_code, response_body, error_object) unless error_object.refund_result.nil?
35
35
  return create_exception_from_response_fields(status_code, response_body, error_object.error_id, error_object.errors, context)
36
36
  end
37
+ return create_exception_from_response_fields(status_code, response_body, nil, [], context) if error_object.nil?
37
38
  raise ArgumentError.new("unsupported error object type: " + error_object.class.name) unless error_object.is_a?(Worldline::Connect::SDK::V1::Domain::ErrorResponse)
38
39
  create_exception_from_response_fields(status_code, response_body, error_object.error_id, error_object.errors, context)
39
40
  end
@@ -303,7 +303,7 @@ describe 'DefaultConnectionLogging' do
303
303
  CLIENT.enable_logging(logger)
304
304
  response = CLIENT.v1.merchant('1234').tokens.delete('5678', nil)
305
305
 
306
- expect(response).to_not be_nil
306
+ expect(response).to be_nil
307
307
 
308
308
  validate_request_and_response(logger.entries[0], logger.entries[1], 'deleteToken')
309
309
  end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'ResponseHeader' do
4
+ ResponseHeader ||= Worldline::Connect::SDK::Communication::ResponseHeader
5
+
6
+ test_data = {
7
+ "attachment; filename=testfile" => "testfile",
8
+ "attachment; filename=\"testfile\"" => "testfile",
9
+ "attachment; filename=\"testfile" => "\"testfile",
10
+ "attachment; filename=testfile\"" => "testfile\"",
11
+ "attachment; filename='testfile'" => "testfile",
12
+ "attachment; filename='testfile" => "'testfile",
13
+ "attachment; filename=testfile'" => "testfile'",
14
+
15
+ "filename=testfile" => "testfile",
16
+ "filename=\"testfile\"" => "testfile",
17
+ "filename=\"testfile" => "\"testfile",
18
+ "filename=testfile\"" => "testfile\"",
19
+ "filename='testfile'" => "testfile",
20
+ "filename='testfile" => "'testfile",
21
+ "filename=testfile'" => "testfile'",
22
+
23
+ "attachment; filename=testfile; x=y" => "testfile",
24
+ "attachment; filename=\"testfile\"; x=y" => "testfile",
25
+ "attachment; filename=\"testfile; x=y" => "\"testfile",
26
+ "attachment; filename=testfile\"; x=y" => "testfile\"",
27
+ "attachment; filename='testfile'; x=y" => "testfile",
28
+ "attachment; filename='testfile; x=y" => "'testfile",
29
+ "attachment; filename=testfile'; x=y" => "testfile'",
30
+
31
+ "attachment" => nil,
32
+
33
+ "filename=\"" => "\"",
34
+ "filename='" => "'",
35
+ }
36
+
37
+ it 'extracts the correct disposition filename from an array of ResponseHeader' do
38
+ test_data.each do |value, expected|
39
+ headers = [ResponseHeader.new('Content-Disposition', value)]
40
+ filename = ResponseHeader.get_disposition_filename(headers)
41
+ expect(filename).to eq(expected)
42
+ end
43
+ headers = []
44
+ filename = ResponseHeader.get_disposition_filename(headers)
45
+ expect(filename).to be_nil
46
+ end
47
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: connect-sdk-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Worldline Global Collect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-06-03 00:00:00.000000000 Z
11
+ date: 2026-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -781,6 +781,7 @@ files:
781
781
  - spec/lib/communication/default_connection_idempotence_spec.rb
782
782
  - spec/lib/communication/default_connection_logger_spec.rb
783
783
  - spec/lib/communication/default_connection_spec.rb
784
+ - spec/lib/communication/response_header_spec.rb
784
785
  - spec/lib/communicator_configuration_spec.rb
785
786
  - spec/lib/communicator_spec.rb
786
787
  - spec/lib/factory_spec.rb
@@ -872,6 +873,7 @@ test_files:
872
873
  - spec/lib/communication/default_connection_idempotence_spec.rb
873
874
  - spec/lib/communication/default_connection_logger_spec.rb
874
875
  - spec/lib/communication/default_connection_spec.rb
876
+ - spec/lib/communication/response_header_spec.rb
875
877
  - spec/lib/communicator_configuration_spec.rb
876
878
  - spec/lib/communicator_spec.rb
877
879
  - spec/lib/factory_spec.rb