pcp-server-ruby-sdk 1.7.0 → 1.9.0

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.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/api-definition.yaml +685 -667
  4. data/lib/PCP-server-Ruby-SDK/endpoints/checkout_api_client.rb +3 -1
  5. data/lib/PCP-server-Ruby-SDK/endpoints/commerce_case_api_client.rb +5 -4
  6. data/lib/PCP-server-Ruby-SDK/endpoints/order_management_checkout_actions_api_client.rb +25 -0
  7. data/lib/PCP-server-Ruby-SDK/models/cancel_payment_request.rb +8 -0
  8. data/lib/PCP-server-Ruby-SDK/models/cart_item_supplier_references.rb +2 -0
  9. data/lib/PCP-server-Ruby-SDK/models/commerce_cases_response.rb +18 -0
  10. data/lib/PCP-server-Ruby-SDK/models/complete_order_request.rb +187 -0
  11. data/lib/PCP-server-Ruby-SDK/models/order_line_details_input.rb +2 -1
  12. data/lib/PCP-server-Ruby-SDK/models/order_line_details_patch.rb +11 -1
  13. data/lib/PCP-server-Ruby-SDK/models/order_line_details_result.rb +11 -1
  14. data/lib/PCP-server-Ruby-SDK/models/payment_event.rb +34 -4
  15. data/lib/PCP-server-Ruby-SDK/models/payment_references_for_refund.rb +198 -0
  16. data/lib/PCP-server-Ruby-SDK/models/redirect_payment_method_specific_input.rb +4 -14
  17. data/lib/PCP-server-Ruby-SDK/models/redirect_payment_method_specific_output.rb +4 -14
  18. data/lib/PCP-server-Ruby-SDK/models/refund_request.rb +1 -1
  19. data/lib/PCP-server-Ruby-SDK/models/required_field_validation.rb +108 -0
  20. data/lib/PCP-server-Ruby-SDK/version.rb +1 -1
  21. data/lib/PCP-server-Ruby-SDK.rb +6 -0
  22. data/package-lock.json +16 -2
  23. data/package.json +1 -1
  24. data/spec/endpoints/checkout_api_client_spec.rb +22 -0
  25. data/spec/endpoints/order_management_checkout_actions_api_client_spec.rb +51 -0
  26. data/spec/models/required_field_validation_spec.rb +551 -0
  27. metadata +14 -8
@@ -0,0 +1,198 @@
1
+ require 'date'
2
+ require 'time'
3
+
4
+ # Object that holds all reference properties for a refund that are linked to this transaction.
5
+ module PCPServerSDK
6
+ module Models
7
+ class PaymentReferencesForRefund
8
+ # Unique reference of the Commerce Case that is also returned for reporting and reconciliation purposes.
9
+ attr_accessor :merchant_reference
10
+
11
+ # Reference to the capture to be refunded.
12
+ attr_accessor :capture_reference
13
+
14
+ # Attribute mapping from ruby-style variable name to JSON key.
15
+ def self.attribute_map
16
+ {
17
+ :'merchant_reference' => :'merchantReference',
18
+ :'capture_reference' => :'captureReference'
19
+ }
20
+ end
21
+
22
+ # Returns all the JSON keys this model knows about
23
+ def self.acceptable_attributes
24
+ attribute_map.values
25
+ end
26
+
27
+ # Attribute type mapping.
28
+ def self.openapi_types
29
+ {
30
+ :'merchant_reference' => :'String',
31
+ :'capture_reference' => :'String'
32
+ }
33
+ end
34
+
35
+ # List of attributes with nullable: true
36
+ def self.openapi_nullable
37
+ Set.new([])
38
+ end
39
+
40
+ # Initializes the object
41
+ # @param [Hash] attributes Model attributes in the form of hash
42
+ def initialize(attributes = {})
43
+ if (!attributes.is_a?(Hash))
44
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentReferencesForRefund` initialize method"
45
+ end
46
+
47
+ # check to see if the attribute exists and convert string to symbol for hash key
48
+ attributes = attributes.each_with_object({}) { |(k, v), h|
49
+ if (!self.class.attribute_map.key?(k.to_sym))
50
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentReferencesForRefund`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
51
+ end
52
+ h[k.to_sym] = v
53
+ }
54
+
55
+ if attributes.key?(:'merchant_reference')
56
+ self.merchant_reference = attributes[:'merchant_reference']
57
+ end
58
+
59
+ if attributes.key?(:'capture_reference')
60
+ self.capture_reference = attributes[:'capture_reference']
61
+ end
62
+ end
63
+
64
+ # Checks equality by comparing each attribute.
65
+ # @param [Object] Object to be compared
66
+ def ==(o)
67
+ return true if self.equal?(o)
68
+ self.class == o.class &&
69
+ merchant_reference == o.merchant_reference &&
70
+ capture_reference == o.capture_reference
71
+ end
72
+
73
+ # @see the `==` method
74
+ # @param [Object] Object to be compared
75
+ def eql?(o)
76
+ self == o
77
+ end
78
+
79
+ # Calculates hash code according to all attributes.
80
+ # @return [Integer] Hash code
81
+ def hash
82
+ [merchant_reference, capture_reference].hash
83
+ end
84
+
85
+ # Builds the object from hash
86
+ # @param [Hash] attributes Model attributes in the form of hash
87
+ # @return [Object] Returns the model itself
88
+ def self.build_from_hash(attributes)
89
+ return nil unless attributes.is_a?(Hash)
90
+ attributes = attributes.transform_keys(&:to_sym)
91
+ transformed_hash = {}
92
+ openapi_types.each_pair do |key, type|
93
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
94
+ transformed_hash["#{key}"] = nil
95
+ elsif type =~ /\AArray<(.*)>/i
96
+ # check to ensure the input is an array given that the attribute
97
+ # is documented as an array but the input is not
98
+ if attributes[attribute_map[key]].is_a?(Array)
99
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
100
+ end
101
+ elsif !attributes[attribute_map[key]].nil?
102
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
103
+ end
104
+ end
105
+ new(transformed_hash)
106
+ end
107
+
108
+ # Deserializes the data based on type
109
+ # @param string type Data type
110
+ # @param string value Value to be deserialized
111
+ # @return [Object] Deserialized data
112
+ def self._deserialize(type, value)
113
+ case type.to_sym
114
+ when :Time
115
+ Time.parse(value)
116
+ when :Date
117
+ Date.parse(value)
118
+ when :String
119
+ value.to_s
120
+ when :Integer
121
+ value.to_i
122
+ when :Float
123
+ value.to_f
124
+ when :Boolean
125
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
126
+ true
127
+ else
128
+ false
129
+ end
130
+ when :Object
131
+ # generic object (usually a Hash), return directly
132
+ value
133
+ when /\AArray<(?<inner_type>.+)>\z/
134
+ inner_type = Regexp.last_match[:inner_type]
135
+ value.map { |v| _deserialize(inner_type, v) }
136
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
137
+ k_type = Regexp.last_match[:k_type]
138
+ v_type = Regexp.last_match[:v_type]
139
+ {}.tap do |hash|
140
+ value.each do |k, v|
141
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
142
+ end
143
+ end
144
+ else # model
145
+ # models (e.g. Pet) or oneOf
146
+ klass = PCPServerSDK::Models.const_get(type)
147
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
148
+ end
149
+ end
150
+
151
+ # Returns the string representation of the object
152
+ # @return [String] String presentation of the object
153
+ def to_s
154
+ to_hash.to_s
155
+ end
156
+
157
+ # to_body is an alias to to_hash (backward compatibility)
158
+ # @return [Hash] Returns the object in the form of hash
159
+ def to_body
160
+ to_hash
161
+ end
162
+
163
+ # Returns the object in the form of hash
164
+ # @return [Hash] Returns the object in the form of hash
165
+ def to_hash
166
+ hash = {}
167
+ self.class.attribute_map.each_pair do |attr, param|
168
+ value = self.send(attr)
169
+ if value.nil?
170
+ is_nullable = self.class.openapi_nullable.include?(attr)
171
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
172
+ end
173
+
174
+ hash[param] = _to_hash(value)
175
+ end
176
+ hash
177
+ end
178
+
179
+ # Outputs non-array value in the form of hash
180
+ # For object, use to_hash. Otherwise, just return the value
181
+ # @param [Object] value Any valid value
182
+ # @return [Hash] Returns the value in the form of hash
183
+ def _to_hash(value)
184
+ if value.is_a?(Array)
185
+ value.compact.map { |v| _to_hash(v) }
186
+ elsif value.is_a?(Hash)
187
+ {}.tap do |hash|
188
+ value.each { |k, v| hash[k] = _to_hash(v) }
189
+ end
190
+ elsif value.respond_to? :to_hash
191
+ value.to_hash
192
+ else
193
+ value
194
+ end
195
+ end
196
+ end
197
+ end
198
+ end
@@ -25,9 +25,6 @@ module PCPServerSDK
25
25
 
26
26
  attr_accessor :redirection_data
27
27
 
28
- # Indicates whether the PayPal JavaScript SDK flow is used on the redirect level.
29
- attr_accessor :java_script_sdk_flow
30
-
31
28
  # Attribute mapping from ruby-style variable name to JSON key.
32
29
  def self.attribute_map
33
30
  {
@@ -37,8 +34,7 @@ module PCPServerSDK
37
34
  :'tokenize' => :'tokenize',
38
35
  :'payment_product_id' => :'paymentProductId',
39
36
  :'payment_product840_specific_input' => :'paymentProduct840SpecificInput',
40
- :'redirection_data' => :'redirectionData',
41
- :'java_script_sdk_flow' => :'javaScriptSdkFlow'
37
+ :'redirection_data' => :'redirectionData'
42
38
  }
43
39
  end
44
40
 
@@ -56,8 +52,7 @@ module PCPServerSDK
56
52
  :'tokenize' => :'Boolean',
57
53
  :'payment_product_id' => :'Integer',
58
54
  :'payment_product840_specific_input' => :'RedirectPaymentProduct840SpecificInput',
59
- :'redirection_data' => :'RedirectionData',
60
- :'java_script_sdk_flow' => :'Boolean'
55
+ :'redirection_data' => :'RedirectionData'
61
56
  }
62
57
  end
63
58
 
@@ -109,10 +104,6 @@ module PCPServerSDK
109
104
  if attributes.key?(:'redirection_data')
110
105
  self.redirection_data = attributes[:'redirection_data']
111
106
  end
112
-
113
- if attributes.key?(:'java_script_sdk_flow')
114
- self.java_script_sdk_flow = attributes[:'java_script_sdk_flow']
115
- end
116
107
  end
117
108
 
118
109
  # Checks equality by comparing each attribute.
@@ -126,8 +117,7 @@ module PCPServerSDK
126
117
  tokenize == o.tokenize &&
127
118
  payment_product_id == o.payment_product_id &&
128
119
  payment_product840_specific_input == o.payment_product840_specific_input &&
129
- redirection_data == o.redirection_data &&
130
- java_script_sdk_flow == o.java_script_sdk_flow
120
+ redirection_data == o.redirection_data
131
121
  end
132
122
 
133
123
  # @see the `==` method
@@ -139,7 +129,7 @@ module PCPServerSDK
139
129
  # Calculates hash code according to all attributes.
140
130
  # @return [Integer] Hash code
141
131
  def hash
142
- [requires_approval, payment_processing_token, reporting_token, tokenize, payment_product_id, payment_product840_specific_input, redirection_data, java_script_sdk_flow].hash
132
+ [requires_approval, payment_processing_token, reporting_token, tokenize, payment_product_id, payment_product840_specific_input, redirection_data].hash
143
133
  end
144
134
 
145
135
  # Builds the object from hash
@@ -17,17 +17,13 @@ module PCPServerSDK
17
17
  # Token to identify the card in the reporting.
18
18
  attr_accessor :reporting_token
19
19
 
20
- # Indicates whether the PayPal JavaScript SDK flow was used for the redirect payment.
21
- attr_accessor :java_script_sdk_flow
22
-
23
20
  # Attribute mapping from ruby-style variable name to JSON key.
24
21
  def self.attribute_map
25
22
  {
26
23
  :'payment_product_id' => :'paymentProductId',
27
24
  :'payment_product840_specific_output' => :'paymentProduct840SpecificOutput',
28
25
  :'payment_processing_token' => :'paymentProcessingToken',
29
- :'reporting_token' => :'reportingToken',
30
- :'java_script_sdk_flow' => :'javaScriptSdkFlow'
26
+ :'reporting_token' => :'reportingToken'
31
27
  }
32
28
  end
33
29
 
@@ -42,8 +38,7 @@ module PCPServerSDK
42
38
  :'payment_product_id' => :'Integer',
43
39
  :'payment_product840_specific_output' => :'PaymentProduct840SpecificOutput',
44
40
  :'payment_processing_token' => :'String',
45
- :'reporting_token' => :'String',
46
- :'java_script_sdk_flow' => :'Boolean'
41
+ :'reporting_token' => :'String'
47
42
  }
48
43
  end
49
44
 
@@ -83,10 +78,6 @@ module PCPServerSDK
83
78
  if attributes.key?(:'reporting_token')
84
79
  self.reporting_token = attributes[:'reporting_token']
85
80
  end
86
-
87
- if attributes.key?(:'java_script_sdk_flow')
88
- self.java_script_sdk_flow = attributes[:'java_script_sdk_flow']
89
- end
90
81
  end
91
82
 
92
83
  # Checks equality by comparing each attribute.
@@ -97,8 +88,7 @@ module PCPServerSDK
97
88
  payment_product_id == o.payment_product_id &&
98
89
  payment_product840_specific_output == o.payment_product840_specific_output &&
99
90
  payment_processing_token == o.payment_processing_token &&
100
- reporting_token == o.reporting_token &&
101
- java_script_sdk_flow == o.java_script_sdk_flow
91
+ reporting_token == o.reporting_token
102
92
  end
103
93
 
104
94
  # @see the `==` method
@@ -110,7 +100,7 @@ module PCPServerSDK
110
100
  # Calculates hash code according to all attributes.
111
101
  # @return [Integer] Hash code
112
102
  def hash
113
- [payment_product_id, payment_product840_specific_output, payment_processing_token, reporting_token, java_script_sdk_flow].hash
103
+ [payment_product_id, payment_product840_specific_output, payment_processing_token, reporting_token].hash
114
104
  end
115
105
 
116
106
  # Builds the object from hash
@@ -33,7 +33,7 @@ module PCPServerSDK
33
33
  def self.openapi_types
34
34
  {
35
35
  :'amount_of_money' => :'PositiveAmountOfMoney',
36
- :'references' => :'PaymentReferences',
36
+ :'references' => :'PaymentReferencesForRefund',
37
37
  :'_return' => :'ReturnInformation',
38
38
  :'fund_split' => :'FundSplit'
39
39
  }
@@ -0,0 +1,108 @@
1
+ require 'date'
2
+ require 'psych'
3
+ require 'set'
4
+
5
+ module PCPServerSDK
6
+ module Models
7
+ module RequiredFieldValidation
8
+ SCHEMA_PATH = File.expand_path('../../../api-definition.yaml', __dir__)
9
+
10
+ class << self
11
+ def install!
12
+ required_attributes_by_class.each do |class_name, required_attributes|
13
+ next unless PCPServerSDK::Models.const_defined?(class_name, false)
14
+
15
+ klass = PCPServerSDK::Models.const_get(class_name)
16
+ next unless klass.is_a?(Class)
17
+ next if klass < Array
18
+ next unless klass.respond_to?(:attribute_map)
19
+ next if klass.instance_variable_defined?(:@required_field_validation_installed)
20
+
21
+ klass.prepend(build_validation_module(required_attributes))
22
+ klass.singleton_class.prepend(build_class_validation_module)
23
+ klass.instance_variable_set(:@required_field_validation_installed, true)
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def build_validation_module(required_attributes)
30
+ Module.new do
31
+ define_method(:initialize) do |attributes = {}|
32
+ @required_field_validation_initializing = true
33
+ initialization_succeeded = false
34
+
35
+ begin
36
+ super(attributes)
37
+ initialization_succeeded = true
38
+ ensure
39
+ @required_field_validation_initializing = false
40
+ end
41
+
42
+ if initialization_succeeded && attributes.is_a?(Hash) && !attributes.empty?
43
+ validate_required_fields!
44
+ end
45
+ end
46
+
47
+ define_method(:validate_required_fields!) do
48
+ missing_attributes = required_attributes.select { |attribute| public_send(attribute).nil? }
49
+ return if missing_attributes.empty?
50
+
51
+ raise ArgumentError, "#{missing_attributes.first} cannot be nil"
52
+ end
53
+
54
+ define_method(:to_hash) do
55
+ validate_required_fields!
56
+ super()
57
+ end
58
+
59
+ required_attributes.each do |attribute|
60
+ define_method("#{attribute}=") do |value|
61
+ if value.nil? && !@required_field_validation_initializing
62
+ raise ArgumentError, "#{attribute} cannot be nil"
63
+ end
64
+
65
+ super(value)
66
+ end
67
+ end
68
+ end
69
+ end
70
+ def build_class_validation_module
71
+ Module.new do
72
+ def build_from_hash(attributes)
73
+ object = super(attributes)
74
+ return object if object.nil?
75
+ return object if object.is_a?(Array)
76
+
77
+ object.send(:validate_required_fields!) if object.respond_to?(:validate_required_fields!, true)
78
+ object
79
+ end
80
+ end
81
+ end
82
+
83
+ def required_attributes_by_class
84
+ @required_attributes_by_class ||= begin
85
+ spec = Psych.safe_load_file(SCHEMA_PATH, permitted_classes: [Time, Date, Symbol], aliases: true)
86
+ schemas = spec.dig('components', 'schemas') || {}
87
+
88
+ schemas.each_with_object({}) do |(schema_name, schema), mapping|
89
+ required_properties = Array(schema['required'])
90
+ next if required_properties.empty?
91
+ next unless PCPServerSDK::Models.const_defined?(schema_name, false)
92
+
93
+ klass = PCPServerSDK::Models.const_get(schema_name)
94
+ next unless klass.is_a?(Class)
95
+ next unless klass.respond_to?(:attribute_map)
96
+
97
+ attribute_map = klass.attribute_map.invert
98
+ required_attributes = required_properties.filter_map { |property| attribute_map[property.to_sym] }
99
+ next if required_attributes.empty?
100
+
101
+ mapping[schema_name] = required_attributes.freeze
102
+ end.freeze
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module PCPServerSDK
3
- VERSION = '1.7.0'
3
+ VERSION = '1.9.0'
4
4
  end
@@ -52,8 +52,10 @@ require_relative 'PCP-server-Ruby-SDK/models/checkout_references'
52
52
  require_relative 'PCP-server-Ruby-SDK/models/checkout_response'
53
53
  require_relative 'PCP-server-Ruby-SDK/models/checkouts_response'
54
54
  require_relative 'PCP-server-Ruby-SDK/models/commerce_case_response'
55
+ require_relative 'PCP-server-Ruby-SDK/models/commerce_cases_response'
55
56
  require_relative 'PCP-server-Ruby-SDK/models/company_information'
56
57
  require_relative 'PCP-server-Ruby-SDK/models/complete_financing_payment_method_specific_input'
58
+ require_relative 'PCP-server-Ruby-SDK/models/complete_order_request'
57
59
  require_relative 'PCP-server-Ruby-SDK/models/complete_payment_method_specific_input'
58
60
  require_relative 'PCP-server-Ruby-SDK/models/complete_payment_request'
59
61
  require_relative 'PCP-server-Ruby-SDK/models/complete_payment_response'
@@ -119,6 +121,7 @@ require_relative 'PCP-server-Ruby-SDK/models/payment_product771_specific_output'
119
121
  require_relative 'PCP-server-Ruby-SDK/models/payment_product840_customer_account'
120
122
  require_relative 'PCP-server-Ruby-SDK/models/payment_product840_specific_output'
121
123
  require_relative 'PCP-server-Ruby-SDK/models/payment_references'
124
+ require_relative 'PCP-server-Ruby-SDK/models/payment_references_for_refund'
122
125
  require_relative 'PCP-server-Ruby-SDK/models/payment_response'
123
126
  require_relative 'PCP-server-Ruby-SDK/models/payment_status_output'
124
127
  require_relative 'PCP-server-Ruby-SDK/models/payment_type'
@@ -173,6 +176,7 @@ require_relative 'PCP-server-Ruby-SDK/models/applepay/apple_pay_payment_data_hea
173
176
  require_relative 'PCP-server-Ruby-SDK/models/applepay/apple_pay_payment_method'
174
177
  require_relative 'PCP-server-Ruby-SDK/models/applepay/apple_pay_payment_method_type'
175
178
  require_relative 'PCP-server-Ruby-SDK/models/applepay/apple_pay_payment_token'
179
+ require_relative 'PCP-server-Ruby-SDK/models/required_field_validation'
176
180
 
177
181
  # Queries
178
182
  require_relative 'PCP-server-Ruby-SDK/queries/get_checkouts_query'
@@ -189,6 +193,8 @@ require_relative 'PCP-server-Ruby-SDK/request_header_generator'
189
193
  require_relative 'PCP-server-Ruby-SDK/version'
190
194
 
191
195
  module PCPServerSDK
196
+ PCPServerSDK::Models::RequiredFieldValidation.install!
197
+
192
198
  class << self
193
199
  # Customize default settings for the SDK using block.
194
200
  # PCPServerSDK.configure do |config|
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pcp-serversdk-ruby",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pcp-serversdk-ruby",
9
- "version": "1.7.0",
9
+ "version": "1.9.0",
10
10
  "devDependencies": {
11
11
  "@commitlint/cli": "19.4.0",
12
12
  "@commitlint/config-conventional": "19.2.2",
@@ -306,6 +306,20 @@
306
306
  "node": ">=10.13.0"
307
307
  }
308
308
  },
309
+ "node_modules/@simple-libs/stream-utils": {
310
+ "version": "1.2.0",
311
+ "resolved": "https://registry.npmjs.org/@simple-libs/stream-utils/-/stream-utils-1.2.0.tgz",
312
+ "integrity": "sha512-KxXvfapcixpz6rVEB6HPjOUZT22yN6v0vI0urQSk1L8MlEWPDFCZkhw2xmkyoTGYeFw7tWTZd7e3lVzRZRN/EA==",
313
+ "dev": true,
314
+ "license": "MIT",
315
+ "optional": true,
316
+ "engines": {
317
+ "node": ">=18"
318
+ },
319
+ "funding": {
320
+ "url": "https://ko-fi.com/dangreen"
321
+ }
322
+ },
309
323
  "node_modules/@types/conventional-commits-parser": {
310
324
  "version": "5.0.2",
311
325
  "resolved": "https://registry.npmjs.org/@types/conventional-commits-parser/-/conventional-commits-parser-5.0.2.tgz",
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pcp-serversdk-ruby",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "type": "commonjs",
5
5
  "scripts": {
6
6
  "changelog": "conventional-changelog -i CHANGELOG.md -s --config ./changelog.config.js"
@@ -255,6 +255,28 @@ RSpec.describe PCPServerSDK::Endpoints::CheckoutApiClient do
255
255
  end
256
256
  end
257
257
 
258
+ describe '#remove_checkout_request' do
259
+ context 'when request is successful' do
260
+ let(:response) { double('Response', body: '{}', code: 200) }
261
+
262
+ before do
263
+ allow(client).to receive(:get_response).and_return(response)
264
+ end
265
+
266
+ it 'does not raise an error' do
267
+ expect { client.remove_checkout_request('1', '2', '3') }.not_to raise_error
268
+ end
269
+ end
270
+
271
+ context 'when some params are nil' do
272
+ it 'raises a TypeError' do
273
+ expect { client.remove_checkout_request(nil, '2', '3') }.to raise_error(TypeError, 'Merchant ID is required')
274
+ expect { client.remove_checkout_request('1', nil, '3') }.to raise_error(TypeError, 'Commerce Case ID is required')
275
+ expect { client.remove_checkout_request('1', '2', nil) }.to raise_error(TypeError, 'Checkout ID is required')
276
+ end
277
+ end
278
+ end
279
+
258
280
  describe '#complete_checkout_request' do
259
281
  let(:payload) { double('PCPServerSDK::Models::CompleteOrderRequest') }
260
282
 
@@ -113,6 +113,57 @@ RSpec.describe PCPServerSDK::Endpoints::OrderManagementCheckoutActionsApiClient
113
113
  end
114
114
  end
115
115
 
116
+ describe '#complete_order' do
117
+ let(:payload) { double('PCPServerSDK::Models::CompleteOrderRequest') }
118
+
119
+ context 'when request is successful' do
120
+ let(:response) { double('Response', body: '{}', code: '200') }
121
+ let(:expected_response) { PCPServerSDK::Models::CompletePaymentResponse.new }
122
+
123
+ before do
124
+ allow(client).to receive(:get_response).and_return(response)
125
+ end
126
+
127
+ it 'returns a successful response' do
128
+ result = client.complete_order('1', '2', '3', payload)
129
+ expect(result).to eq(expected_response)
130
+ end
131
+ end
132
+
133
+ context 'when request is unsuccessful (400)' do
134
+ let(:response) { double('Response', body: error_body, code: '400') }
135
+
136
+ before do
137
+ allow(client).to receive(:get_response).and_return(response)
138
+ end
139
+
140
+ it 'raises an PCPServerSDK::Errors::ApiErrorResponseException' do
141
+ expect { client.complete_order('1', '2', '3', payload) }.to raise_error(PCPServerSDK::Errors::ApiErrorResponseException)
142
+ end
143
+ end
144
+
145
+ context 'when request is unsuccessful (500)' do
146
+ let(:response) { double('Response', body: '{}', code: '500') }
147
+
148
+ before do
149
+ allow(client).to receive(:get_response).and_return(response)
150
+ end
151
+
152
+ it 'raises an PCPServerSDK::Errors::ApiResponseRetrievalException' do
153
+ expect { client.complete_order('1', '2', '3', payload) }.to raise_error(PCPServerSDK::Errors::ApiResponseRetrievalException)
154
+ end
155
+ end
156
+
157
+ context 'when some params are nil' do
158
+ it 'raises a TypeError' do
159
+ expect { client.complete_order(nil, '2', '3', payload) }.to raise_error(TypeError, 'Merchant ID is required')
160
+ expect { client.complete_order('1', nil, '3', payload) }.to raise_error(TypeError, 'Commerce Case ID is required')
161
+ expect { client.complete_order('1', '2', nil, payload) }.to raise_error(TypeError, 'Checkout ID is required')
162
+ expect { client.complete_order('1', '2', '3', nil) }.to raise_error(TypeError, 'Payload is required')
163
+ end
164
+ end
165
+ end
166
+
116
167
  describe '#return_order' do
117
168
  let(:payload) { double('PCPServerSDK::Models::ReturnRequest') }
118
169