connect-sdk-ruby 4.7.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: c175de9bd17c5518450db6d0a1f1ef001ac70ba09a38d8854f351ac646d77ea3
4
- data.tar.gz: 722654abe776e9d14770ce84ebb82e968d91d4b9497837ead0c4c4bfb04089b0
3
+ metadata.gz: 58cbad6e878461552ac4206cf9951c00a9dcaf15224b58b75e8296217f6aba0c
4
+ data.tar.gz: 5669d32653bf1f26c277c873e60452bb4862e7e52cd0a94777bd1e9a45e0a06c
5
5
  SHA512:
6
- metadata.gz: 32863cf1531fe7c647e414c3328268be461c295cd060154ee8ea8c2f1e5cf27b588f898a040a3b80d8ee39d8b578f1e4b0eb07cababd43e7c591b8126913af15
7
- data.tar.gz: 44e293a08fe576df338917ac833f92308ff8f7e7f669d8bc3825edc0fe2c631aa3531a46fb5ef13f052d5353c22d75b828b07ce93ec5503feaad9158cc1baa84
6
+ metadata.gz: 0ffbd46cde3450c1b117ecadfbf6f63ca22a693b1d6f01f08b0c5ecf5a28a7e1de06284306f5e1bd9266be7734e3ed090d029bddee5091ca6ee18c5d0cf78d32
7
+ data.tar.gz: 6a98c7656ea0a68938d7b1490cb956ae892939f7507a90da316802fbb1ec47026b07f1b85dec58ce339cae2cf1554f8b724196904824b93ed3fb46c63b49b226
data/README.md CHANGED
@@ -27,7 +27,7 @@ Note that the source code of the unit tests, integration tests and the examples
27
27
 
28
28
  ## Requirements
29
29
 
30
- Ruby 2.3 or higher is required.
30
+ Ruby 2.7 or higher is required.
31
31
  As for JRuby, version 9.0.0.0 and higher are supported.
32
32
  In addition, the following packages are required:
33
33
 
@@ -91,11 +91,11 @@ In addition, to run the proxy integration tests, the proxy URI, username and pas
91
91
 
92
92
  In order to run the unit and integration tests, some additional dependencies are required:
93
93
 
94
- * [rake](https://ruby.github.io/rake/) 12.3.3 or higher
95
- * [rspec](https://github.com/rspec/rspec) 3.5 or higher
96
- * [webmock](https://github.com/bblimke/webmock) 2.1 or higher
97
- * [sinatra](https://github.com/sinatra/sinatra) 2.1 or higher
98
- * [webrick](https://github.com/ruby/webrick) 1.7 or higher
94
+ * [rake](https://ruby.github.io/rake/) 13.4 or higher
95
+ * [rspec](https://github.com/rspec/rspec) 3.13 or higher
96
+ * [webmock](https://github.com/bblimke/webmock) 3.26 or higher
97
+ * [sinatra](https://github.com/sinatra/sinatra) 4.2 or higher
98
+ * [webrick](https://github.com/ruby/webrick) 1.9 or higher
99
99
 
100
100
  They can be installed using the following command:
101
101
 
@@ -127,7 +127,7 @@ The following commands can now be executed from the root directory of the SDK fo
127
127
 
128
128
  Documentation can be generated with YARD. YARD can be installed as a gem. The gems required to generate documentation are:
129
129
 
130
- * [rake](https://ruby.github.io/rake/) 12.3.3 or higher
130
+ * [rake](https://ruby.github.io/rake/) 13.4 or higher
131
131
  * [yard](https://github.com/lsegal/yard) 0.9.5 or higher
132
132
 
133
133
  They can be installed using the following command:
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'connect-sdk-ruby'
3
- spec.version = '4.7.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}
@@ -21,10 +21,10 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency 'concurrent-ruby', '~>1.0'
22
22
 
23
23
  spec.add_development_dependency 'yard', '~> 0.9'
24
- spec.add_development_dependency 'rspec', '~> 3.5'
25
- spec.add_development_dependency 'webmock', '~> 2.1'
26
- spec.add_development_dependency 'sinatra', '~> 2.1'
27
- spec.add_development_dependency 'webrick', '~> 1.7'
28
- spec.add_development_dependency 'rake', '~> 12.3', '>= 12.3.3'
24
+ spec.add_development_dependency 'rspec', '~> 3.13'
25
+ spec.add_development_dependency 'webmock', '~> 3.26'
26
+ spec.add_development_dependency 'sinatra', '~> 4.2'
27
+ spec.add_development_dependency 'webrick', '~> 1.9'
28
+ spec.add_development_dependency 'rake', '~> 13.4'
29
29
  # spec.metadata['yard.run'] = 'yri' # compiles yard doc on install
30
30
  end
@@ -14,7 +14,7 @@ module Worldline
14
14
  class MetadataProvider
15
15
  private
16
16
 
17
- SDK_VERSION = '4.7.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
@@ -5,7 +5,7 @@
5
5
  require 'worldline/connect/sdk/domain/data_object'
6
6
  require 'worldline/connect/sdk/v1/domain/capture_payment_order_additional_input'
7
7
  require 'worldline/connect/sdk/v1/domain/capture_payment_order_references'
8
- require 'worldline/connect/sdk/v1/domain/shipping'
8
+ require 'worldline/connect/sdk/v1/domain/capture_payment_shipping'
9
9
 
10
10
  module Worldline
11
11
  module Connect
@@ -14,7 +14,7 @@ module Worldline
14
14
  module Domain
15
15
  # @attr [Worldline::Connect::SDK::V1::Domain::CapturePaymentOrderAdditionalInput] additional_input
16
16
  # @attr [Worldline::Connect::SDK::V1::Domain::CapturePaymentOrderReferences] references
17
- # @attr [Worldline::Connect::SDK::V1::Domain::Shipping] shipping
17
+ # @attr [Worldline::Connect::SDK::V1::Domain::CapturePaymentShipping] shipping
18
18
  class CapturePaymentOrder < Worldline::Connect::SDK::Domain::DataObject
19
19
 
20
20
  attr_accessor :additional_input
@@ -44,7 +44,7 @@ module Worldline
44
44
  end
45
45
  if hash.has_key? 'shipping'
46
46
  raise TypeError, "value '%s' is not a Hash" % [hash['shipping']] unless hash['shipping'].is_a? Hash
47
- @shipping = Worldline::Connect::SDK::V1::Domain::Shipping.new_from_hash(hash['shipping'])
47
+ @shipping = Worldline::Connect::SDK::V1::Domain::CapturePaymentShipping.new_from_hash(hash['shipping'])
48
48
  end
49
49
  end
50
50
  end
@@ -0,0 +1,58 @@
1
+ #
2
+ # This class was auto-generated from the API references found at
3
+ # https://apireference.connect.worldline-solutions.com/
4
+ #
5
+ require 'worldline/connect/sdk/domain/data_object'
6
+ require 'worldline/connect/sdk/v1/domain/address_personal'
7
+
8
+ module Worldline
9
+ module Connect
10
+ module SDK
11
+ module V1
12
+ module Domain
13
+ # @attr [Worldline::Connect::SDK::V1::Domain::AddressPersonal] address
14
+ # @attr [String] email_address
15
+ # @attr [String] shipped_from_zip
16
+ # @attr [String] tracking_number
17
+ class CapturePaymentShipping < Worldline::Connect::SDK::Domain::DataObject
18
+
19
+ attr_accessor :address
20
+
21
+ attr_accessor :email_address
22
+
23
+ attr_accessor :shipped_from_zip
24
+
25
+ attr_accessor :tracking_number
26
+
27
+ # @return (Hash)
28
+ def to_h
29
+ hash = super
30
+ hash['address'] = @address.to_h unless @address.nil?
31
+ hash['emailAddress'] = @email_address unless @email_address.nil?
32
+ hash['shippedFromZip'] = @shipped_from_zip unless @shipped_from_zip.nil?
33
+ hash['trackingNumber'] = @tracking_number unless @tracking_number.nil?
34
+ hash
35
+ end
36
+
37
+ def from_hash(hash)
38
+ super
39
+ if hash.has_key? 'address'
40
+ raise TypeError, "value '%s' is not a Hash" % [hash['address']] unless hash['address'].is_a? Hash
41
+ @address = Worldline::Connect::SDK::V1::Domain::AddressPersonal.new_from_hash(hash['address'])
42
+ end
43
+ if hash.has_key? 'emailAddress'
44
+ @email_address = hash['emailAddress']
45
+ end
46
+ if hash.has_key? 'shippedFromZip'
47
+ @shipped_from_zip = hash['shippedFromZip']
48
+ end
49
+ if hash.has_key? 'trackingNumber'
50
+ @tracking_number = hash['trackingNumber']
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ 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: 4.7.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-04-30 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
@@ -58,76 +58,70 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.5'
61
+ version: '3.13'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.5'
68
+ version: '3.13'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.1'
75
+ version: '3.26'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '2.1'
82
+ version: '3.26'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: sinatra
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '2.1'
89
+ version: '4.2'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '2.1'
96
+ version: '4.2'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: webrick
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.7'
103
+ version: '1.9'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '1.7'
110
+ version: '1.9'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '12.3'
118
- - - ">="
119
- - !ruby/object:Gem::Version
120
- version: 12.3.3
117
+ version: '13.4'
121
118
  type: :development
122
119
  prerelease: false
123
120
  version_requirements: !ruby/object:Gem::Requirement
124
121
  requirements:
125
122
  - - "~>"
126
123
  - !ruby/object:Gem::Version
127
- version: '12.3'
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- version: 12.3.3
124
+ version: '13.4'
131
125
  description: SDK to communicate with the Worldline Global Collect platform using the
132
126
  Worldline Connect Server API
133
127
  email:
@@ -341,6 +335,7 @@ files:
341
335
  - lib/worldline/connect/sdk/v1/domain/capture_payment_order_additional_input.rb
342
336
  - lib/worldline/connect/sdk/v1/domain/capture_payment_order_references.rb
343
337
  - lib/worldline/connect/sdk/v1/domain/capture_payment_request.rb
338
+ - lib/worldline/connect/sdk/v1/domain/capture_payment_shipping.rb
344
339
  - lib/worldline/connect/sdk/v1/domain/capture_response.rb
345
340
  - lib/worldline/connect/sdk/v1/domain/capture_status_output.rb
346
341
  - lib/worldline/connect/sdk/v1/domain/captures_response.rb
@@ -786,6 +781,7 @@ files:
786
781
  - spec/lib/communication/default_connection_idempotence_spec.rb
787
782
  - spec/lib/communication/default_connection_logger_spec.rb
788
783
  - spec/lib/communication/default_connection_spec.rb
784
+ - spec/lib/communication/response_header_spec.rb
789
785
  - spec/lib/communicator_configuration_spec.rb
790
786
  - spec/lib/communicator_spec.rb
791
787
  - spec/lib/factory_spec.rb
@@ -877,6 +873,7 @@ test_files:
877
873
  - spec/lib/communication/default_connection_idempotence_spec.rb
878
874
  - spec/lib/communication/default_connection_logger_spec.rb
879
875
  - spec/lib/communication/default_connection_spec.rb
876
+ - spec/lib/communication/response_header_spec.rb
880
877
  - spec/lib/communicator_configuration_spec.rb
881
878
  - spec/lib/communicator_spec.rb
882
879
  - spec/lib/factory_spec.rb