pcp-server-ruby-sdk 1.12.0 → 1.13.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 (168) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +1 -1
  4. data/api-definition.yaml +323 -41
  5. data/lib/PCP-server-Ruby-SDK/endpoints/payment_intent_api_client.rb +37 -0
  6. data/lib/PCP-server-Ruby-SDK/models/address.rb +9 -237
  7. data/lib/PCP-server-Ruby-SDK/models/address_personal.rb +10 -246
  8. data/lib/PCP-server-Ruby-SDK/models/amount_of_money.rb +4 -195
  9. data/lib/PCP-server-Ruby-SDK/models/api_error.rb +27 -232
  10. data/lib/PCP-server-Ruby-SDK/models/apple_payment_data_token_header_information.rb +6 -194
  11. data/lib/PCP-server-Ruby-SDK/models/apple_payment_data_token_information.rb +8 -229
  12. data/lib/PCP-server-Ruby-SDK/models/bank_account_information.rb +11 -207
  13. data/lib/PCP-server-Ruby-SDK/models/bank_payout_method_specific_input.rb +4 -187
  14. data/lib/PCP-server-Ruby-SDK/models/cancel_item.rb +6 -195
  15. data/lib/PCP-server-Ruby-SDK/models/cancel_payment_request.rb +6 -222
  16. data/lib/PCP-server-Ruby-SDK/models/cancel_payment_response.rb +4 -190
  17. data/lib/PCP-server-Ruby-SDK/models/cancel_request.rb +6 -224
  18. data/lib/PCP-server-Ruby-SDK/models/cancel_response.rb +4 -190
  19. data/lib/PCP-server-Ruby-SDK/models/capture_output.rb +9 -214
  20. data/lib/PCP-server-Ruby-SDK/models/capture_payment_request.rb +14 -253
  21. data/lib/PCP-server-Ruby-SDK/models/capture_payment_response.rb +7 -239
  22. data/lib/PCP-server-Ruby-SDK/models/card_fraud_results.rb +29 -184
  23. data/lib/PCP-server-Ruby-SDK/models/card_info.rb +3 -182
  24. data/lib/PCP-server-Ruby-SDK/models/card_payment_details.rb +8 -210
  25. data/lib/PCP-server-Ruby-SDK/models/card_payment_method_specific_input.rb +32 -307
  26. data/lib/PCP-server-Ruby-SDK/models/card_payment_method_specific_output.rb +6 -210
  27. data/lib/PCP-server-Ruby-SDK/models/card_recurrence_details.rb +12 -186
  28. data/lib/PCP-server-Ruby-SDK/models/cart_item_data.rb +10 -0
  29. data/lib/PCP-server-Ruby-SDK/models/cart_item_input.rb +5 -198
  30. data/lib/PCP-server-Ruby-SDK/models/cart_item_invoice_data.rb +5 -184
  31. data/lib/PCP-server-Ruby-SDK/models/cart_item_order_status.rb +4 -213
  32. data/lib/PCP-server-Ruby-SDK/models/cart_item_patch.rb +5 -200
  33. data/lib/PCP-server-Ruby-SDK/models/cart_item_result.rb +5 -200
  34. data/lib/PCP-server-Ruby-SDK/models/cart_item_supplier_references.rb +6 -195
  35. data/lib/PCP-server-Ruby-SDK/models/checkout_references.rb +4 -192
  36. data/lib/PCP-server-Ruby-SDK/models/checkout_response.rb +15 -319
  37. data/lib/PCP-server-Ruby-SDK/models/checkouts_response.rb +4 -193
  38. data/lib/PCP-server-Ruby-SDK/models/company_information.rb +3 -182
  39. data/lib/PCP-server-Ruby-SDK/models/complete_financing_payment_method_specific_input.rb +12 -202
  40. data/lib/PCP-server-Ruby-SDK/models/complete_order_request.rb +3 -181
  41. data/lib/PCP-server-Ruby-SDK/models/complete_payment_method_specific_input.rb +4 -191
  42. data/lib/PCP-server-Ruby-SDK/models/complete_payment_product840_specific_input.rb +7 -226
  43. data/lib/PCP-server-Ruby-SDK/models/complete_payment_request.rb +6 -209
  44. data/lib/PCP-server-Ruby-SDK/models/complete_payment_response.rb +5 -199
  45. data/lib/PCP-server-Ruby-SDK/models/complete_redirect_payment_method_specific_input.rb +4 -192
  46. data/lib/PCP-server-Ruby-SDK/models/contact_details.rb +4 -191
  47. data/lib/PCP-server-Ruby-SDK/models/create_checkout_request.rb +13 -240
  48. data/lib/PCP-server-Ruby-SDK/models/create_checkout_response.rb +16 -307
  49. data/lib/PCP-server-Ruby-SDK/models/create_commerce_case_response.rb +7 -219
  50. data/lib/PCP-server-Ruby-SDK/models/create_payment_intent.rb +11 -0
  51. data/lib/PCP-server-Ruby-SDK/models/create_payment_intent_request.rb +13 -0
  52. data/lib/PCP-server-Ruby-SDK/models/create_payment_intent_response.rb +10 -0
  53. data/lib/PCP-server-Ruby-SDK/models/create_payment_response.rb +7 -218
  54. data/lib/PCP-server-Ruby-SDK/models/customer.rb +28 -260
  55. data/lib/PCP-server-Ruby-SDK/models/customer_account.rb +10 -44
  56. data/lib/PCP-server-Ruby-SDK/models/customer_device.rb +8 -209
  57. data/lib/PCP-server-Ruby-SDK/models/deliver_item.rb +6 -195
  58. data/lib/PCP-server-Ruby-SDK/models/deliver_request.rb +10 -246
  59. data/lib/PCP-server-Ruby-SDK/models/deliver_response.rb +4 -191
  60. data/lib/PCP-server-Ruby-SDK/models/delivery_information.rb +3 -185
  61. data/lib/PCP-server-Ruby-SDK/models/error_response.rb +4 -193
  62. data/lib/PCP-server-Ruby-SDK/models/financing_payment_method_specific_input.rb +15 -203
  63. data/lib/PCP-server-Ruby-SDK/models/financing_payment_method_specific_output.rb +10 -196
  64. data/lib/PCP-server-Ruby-SDK/models/fund_distribution.rb +12 -263
  65. data/lib/PCP-server-Ruby-SDK/models/fund_split.rb +5 -205
  66. data/lib/PCP-server-Ruby-SDK/models/fund_split_request.rb +3 -147
  67. data/lib/PCP-server-Ruby-SDK/models/fund_split_response.rb +10 -174
  68. data/lib/PCP-server-Ruby-SDK/models/installment_option.rb +13 -273
  69. data/lib/PCP-server-Ruby-SDK/models/link_information.rb +4 -196
  70. data/lib/PCP-server-Ruby-SDK/models/merchant_action.rb +16 -194
  71. data/lib/PCP-server-Ruby-SDK/models/mobile_payment_method_specific_input.rb +13 -246
  72. data/lib/PCP-server-Ruby-SDK/models/mobile_payment_method_specific_output.rb +7 -219
  73. data/lib/PCP-server-Ruby-SDK/models/mobile_payment_three_dsecure.rb +3 -179
  74. data/lib/PCP-server-Ruby-SDK/models/model_base.rb +147 -0
  75. data/lib/PCP-server-Ruby-SDK/models/order.rb +7 -221
  76. data/lib/PCP-server-Ruby-SDK/models/order_item.rb +6 -197
  77. data/lib/PCP-server-Ruby-SDK/models/order_line_details_input.rb +29 -305
  78. data/lib/PCP-server-Ruby-SDK/models/order_line_details_patch.rb +5 -326
  79. data/lib/PCP-server-Ruby-SDK/models/order_line_details_result.rb +5 -326
  80. data/lib/PCP-server-Ruby-SDK/models/order_request.rb +7 -244
  81. data/lib/PCP-server-Ruby-SDK/models/order_response.rb +4 -192
  82. data/lib/PCP-server-Ruby-SDK/models/patch_checkout_request.rb +8 -228
  83. data/lib/PCP-server-Ruby-SDK/models/patch_commerce_case_request.rb +3 -183
  84. data/lib/PCP-server-Ruby-SDK/models/pause_payment_request.rb +2 -165
  85. data/lib/PCP-server-Ruby-SDK/models/pause_payment_response.rb +3 -186
  86. data/lib/PCP-server-Ruby-SDK/models/payee.rb +6 -204
  87. data/lib/PCP-server-Ruby-SDK/models/payment_creation_output.rb +3 -183
  88. data/lib/PCP-server-Ruby-SDK/models/payment_event.rb +19 -274
  89. data/lib/PCP-server-Ruby-SDK/models/payment_execution.rb +29 -335
  90. data/lib/PCP-server-Ruby-SDK/models/payment_execution_request.rb +4 -191
  91. data/lib/PCP-server-Ruby-SDK/models/payment_execution_specific_input.rb +6 -212
  92. data/lib/PCP-server-Ruby-SDK/models/payment_information_refund_request.rb +7 -205
  93. data/lib/PCP-server-Ruby-SDK/models/payment_information_refund_response.rb +5 -196
  94. data/lib/PCP-server-Ruby-SDK/models/payment_information_request.rb +10 -249
  95. data/lib/PCP-server-Ruby-SDK/models/payment_information_response.rb +30 -314
  96. data/lib/PCP-server-Ruby-SDK/models/payment_instructions.rb +8 -214
  97. data/lib/PCP-server-Ruby-SDK/models/payment_intent_output.rb +13 -0
  98. data/lib/PCP-server-Ruby-SDK/models/payment_intent_response.rb +13 -0
  99. data/lib/PCP-server-Ruby-SDK/models/payment_intent_response_data.rb +12 -0
  100. data/lib/PCP-server-Ruby-SDK/models/payment_method_specific_input.rb +9 -261
  101. data/lib/PCP-server-Ruby-SDK/models/payment_method_specific_input_for_intent.rb +9 -0
  102. data/lib/PCP-server-Ruby-SDK/models/payment_output.rb +11 -255
  103. data/lib/PCP-server-Ruby-SDK/models/payment_product302_specific_input.rb +11 -225
  104. data/lib/PCP-server-Ruby-SDK/models/payment_product3391_specific_input.rb +6 -197
  105. data/lib/PCP-server-Ruby-SDK/models/payment_product3391_specific_output.rb +3 -185
  106. data/lib/PCP-server-Ruby-SDK/models/payment_product3392_specific_input.rb +3 -185
  107. data/lib/PCP-server-Ruby-SDK/models/payment_product5002_specific_input.rb +7 -203
  108. data/lib/PCP-server-Ruby-SDK/models/payment_product771_specific_output.rb +3 -183
  109. data/lib/PCP-server-Ruby-SDK/models/payment_product840_customer_account.rb +6 -210
  110. data/lib/PCP-server-Ruby-SDK/models/payment_product840_specific_output.rb +5 -209
  111. data/lib/PCP-server-Ruby-SDK/models/payment_product840_specific_output_data.rb +11 -0
  112. data/lib/PCP-server-Ruby-SDK/models/payment_product840_specific_output_for_intent.rb +13 -0
  113. data/lib/PCP-server-Ruby-SDK/models/payment_references.rb +6 -184
  114. data/lib/PCP-server-Ruby-SDK/models/payment_references_for_refund.rb +12 -197
  115. data/lib/PCP-server-Ruby-SDK/models/payment_response.rb +6 -234
  116. data/lib/PCP-server-Ruby-SDK/models/payment_status_output.rb +6 -234
  117. data/lib/PCP-server-Ruby-SDK/models/payout_output.rb +5 -205
  118. data/lib/PCP-server-Ruby-SDK/models/payout_response.rb +6 -215
  119. data/lib/PCP-server-Ruby-SDK/models/personal_information.rb +11 -227
  120. data/lib/PCP-server-Ruby-SDK/models/personal_name.rb +5 -201
  121. data/lib/PCP-server-Ruby-SDK/models/positive_amount_of_money.rb +4 -196
  122. data/lib/PCP-server-Ruby-SDK/models/processing_mandate_information.rb +9 -254
  123. data/lib/PCP-server-Ruby-SDK/models/redirect_data.rb +3 -183
  124. data/lib/PCP-server-Ruby-SDK/models/redirect_payment_method_specific_input.rb +14 -249
  125. data/lib/PCP-server-Ruby-SDK/models/redirect_payment_method_specific_input_for_intent.rb +12 -0
  126. data/lib/PCP-server-Ruby-SDK/models/redirect_payment_method_specific_output.rb +6 -211
  127. data/lib/PCP-server-Ruby-SDK/models/redirect_payment_method_specific_output_for_create_intent.rb +12 -0
  128. data/lib/PCP-server-Ruby-SDK/models/redirect_payment_method_specific_output_for_intent.rb +10 -0
  129. data/lib/PCP-server-Ruby-SDK/models/redirect_payment_product840_specific_input.rb +6 -205
  130. data/lib/PCP-server-Ruby-SDK/models/redirect_payment_product840_specific_input_data.rb +10 -0
  131. data/lib/PCP-server-Ruby-SDK/models/redirect_payment_product900_specific_input.rb +12 -177
  132. data/lib/PCP-server-Ruby-SDK/models/redirection_data.rb +11 -186
  133. data/lib/PCP-server-Ruby-SDK/models/references.rb +47 -205
  134. data/lib/PCP-server-Ruby-SDK/models/refresh_payment_request.rb +3 -186
  135. data/lib/PCP-server-Ruby-SDK/models/refund_error_response.rb +4 -193
  136. data/lib/PCP-server-Ruby-SDK/models/refund_output.rb +8 -211
  137. data/lib/PCP-server-Ruby-SDK/models/refund_payment_response.rb +7 -242
  138. data/lib/PCP-server-Ruby-SDK/models/refund_request.rb +6 -210
  139. data/lib/PCP-server-Ruby-SDK/models/return_information.rb +4 -194
  140. data/lib/PCP-server-Ruby-SDK/models/return_item.rb +6 -196
  141. data/lib/PCP-server-Ruby-SDK/models/return_request.rb +6 -234
  142. data/lib/PCP-server-Ruby-SDK/models/return_response.rb +4 -191
  143. data/lib/PCP-server-Ruby-SDK/models/sepa_direct_debit_payment_method_specific_input.rb +4 -193
  144. data/lib/PCP-server-Ruby-SDK/models/sepa_direct_debit_payment_method_specific_output.rb +4 -193
  145. data/lib/PCP-server-Ruby-SDK/models/sepa_direct_debit_payment_product771_specific_input.rb +4 -192
  146. data/lib/PCP-server-Ruby-SDK/models/sepa_transfer_payment_product_772_specific_input.rb +3 -186
  147. data/lib/PCP-server-Ruby-SDK/models/shipping.rb +3 -183
  148. data/lib/PCP-server-Ruby-SDK/models/shipping_address.rb +14 -0
  149. data/lib/PCP-server-Ruby-SDK/models/shopping_cart_data.rb +9 -0
  150. data/lib/PCP-server-Ruby-SDK/models/shopping_cart_input.rb +3 -185
  151. data/lib/PCP-server-Ruby-SDK/models/shopping_cart_patch.rb +3 -185
  152. data/lib/PCP-server-Ruby-SDK/models/shopping_cart_result.rb +3 -185
  153. data/lib/PCP-server-Ruby-SDK/models/status_output.rb +21 -264
  154. data/lib/PCP-server-Ruby-SDK/models/three_d_secure_results.rb +6 -226
  155. data/lib/PCP-server-Ruby-SDK/version.rb +1 -1
  156. data/lib/PCP-server-Ruby-SDK.rb +18 -0
  157. data/package-lock.json +2 -2
  158. data/package.json +1 -1
  159. data/scripts/convert_models_to_model_base.rb +128 -0
  160. data/spec/endpoints/payment_intent_api_client_spec.rb +43 -0
  161. data/spec/models/api_definition_conformance_spec.rb +88 -0
  162. data/spec/models/model_base_spec.rb +87 -0
  163. data/spec/models/payment_intent_models_spec.rb +25 -0
  164. data/spec/models/required_field_validation_spec.rb +5 -5
  165. metadata +35 -11
  166. data/lib/PCP-server-Ruby-SDK/models/action_type.rb +0 -34
  167. data/lib/PCP-server-Ruby-SDK/models/avs_result.rb +0 -52
  168. data/lib/PCP-server-Ruby-SDK/models/business_relation.rb +0 -30
@@ -1,234 +1,14 @@
1
+ require_relative 'model_base'
1
2
 
2
- require 'date'
3
- require 'time'
4
-
5
- # 3D Secure results object
6
3
  module PCPServerSDK
7
4
  module Models
8
- class ThreeDSecureResults
5
+ class ThreeDSecureResults < ModelBase
9
6
  # 3D Secure Protocol version used during this transaction.
10
- attr_accessor :version
11
-
7
+ attribute :version, :version, :String
12
8
  # 3D Secure ECI (Electronic Commerce Indicator) depending on the Scheme. Returned by DS.
13
- attr_accessor :scheme_eci
14
-
15
- # Exemption requested and applied in the authorization.
16
- attr_accessor :applied_exemption
17
-
18
-
19
-
20
- class EnumAttributeValidator
21
- attr_reader :datatype
22
- attr_reader :allowable_values
23
-
24
- def initialize(datatype, allowable_values)
25
- @allowable_values = allowable_values.map do |value|
26
- case datatype.to_s
27
- when /Integer/i
28
- value.to_i
29
- when /Float/i
30
- value.to_f
31
- else
32
- value
33
- end
34
- end
35
- end
36
-
37
- def valid?(value)
38
- !value || allowable_values.include?(value)
39
- end
40
- end
41
-
42
- # Attribute mapping from ruby-style variable name to JSON key.
43
- def self.attribute_map
44
- {
45
- :'version' => :'version',
46
- :'scheme_eci' => :'schemeEci',
47
- :'applied_exemption' => :'appliedExemption'
48
- }
49
- end
50
-
51
- # Returns all the JSON keys this model knows about
52
- def self.acceptable_attributes
53
- attribute_map.values
54
- end
55
-
56
- # Attribute type mapping.
57
- def self.openapi_types
58
- {
59
- :'version' => :'String',
60
- :'scheme_eci' => :'String',
61
- :'applied_exemption' => :'String'
62
- }
63
- end
64
-
65
- # List of attributes with nullable: true
66
- def self.openapi_nullable
67
- Set.new([
68
- ])
69
- end
70
-
71
- # Initializes the object
72
- # @param [Hash] attributes Model attributes in the form of hash
73
- def initialize(attributes = {})
74
- if (!attributes.is_a?(Hash))
75
- fail ArgumentError, "The input argument (attributes) must be a hash in `ThreeDSecureResults` initialize method"
76
- end
77
-
78
- # check to see if the attribute exists and convert string to symbol for hash key
79
- attributes = attributes.each_with_object({}) { |(k, v), h|
80
- if (!self.class.attribute_map.key?(k.to_sym))
81
- fail ArgumentError, "`#{k}` is not a valid attribute in `ThreeDSecureResults`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
82
- end
83
- h[k.to_sym] = v
84
- }
85
-
86
- if attributes.key?(:'version')
87
- self.version = attributes[:'version']
88
- end
89
-
90
- if attributes.key?(:'scheme_eci')
91
- self.scheme_eci = attributes[:'scheme_eci']
92
- end
93
-
94
- if attributes.key?(:'applied_exemption')
95
- self.applied_exemption = attributes[:'applied_exemption']
96
- end
97
- end
98
-
99
- # Checks equality by comparing each attribute.
100
- # @param [Object] Object to be compared
101
- def ==(o)
102
- return true if self.equal?(o)
103
- self.class == o.class &&
104
- version == o.version &&
105
- scheme_eci == o.scheme_eci &&
106
- applied_exemption == o.applied_exemption
107
- end
108
-
109
- # @see the `==` method
110
- # @param [Object] Object to be compared
111
- def eql?(o)
112
- self == o
113
- end
114
-
115
- # Calculates hash code according to all attributes.
116
- # @return [Integer] Hash code
117
- def hash
118
- [version, scheme_eci, applied_exemption].hash
119
- end
120
-
121
- # Builds the object from hash
122
- # @param [Hash] attributes Model attributes in the form of hash
123
- # @return [Object] Returns the model itself
124
- def self.build_from_hash(attributes)
125
- return nil unless attributes.is_a?(Hash)
126
- attributes = attributes.transform_keys(&:to_sym)
127
- transformed_hash = {}
128
- openapi_types.each_pair do |key, type|
129
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
130
- transformed_hash["#{key}"] = nil
131
- elsif type =~ /\AArray<(.*)>/i
132
- # check to ensure the input is an array given that the attribute
133
- # is documented as an array but the input is not
134
- if attributes[attribute_map[key]].is_a?(Array)
135
- transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
136
- end
137
- elsif !attributes[attribute_map[key]].nil?
138
- transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
139
- end
140
- end
141
- new(transformed_hash)
142
- end
143
-
144
- # Deserializes the data based on type
145
- # @param string type Data type
146
- # @param string value Value to be deserialized
147
- # @return [Object] Deserialized data
148
- def self._deserialize(type, value)
149
- case type.to_sym
150
- when :Time
151
- Time.parse(value)
152
- when :Date
153
- Date.parse(value)
154
- when :String
155
- value.to_s
156
- when :Integer
157
- value.to_i
158
- when :Float
159
- value.to_f
160
- when :Boolean
161
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
162
- true
163
- else
164
- false
165
- end
166
- when :Object
167
- # generic object (usually a Hash), return directly
168
- value
169
- when /\AArray<(?<inner_type>.+)>\z/
170
- inner_type = Regexp.last_match[:inner_type]
171
- value.map { |v| _deserialize(inner_type, v) }
172
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
173
- k_type = Regexp.last_match[:k_type]
174
- v_type = Regexp.last_match[:v_type]
175
- {}.tap do |hash|
176
- value.each do |k, v|
177
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
178
- end
179
- end
180
- else # model
181
- # models (e.g. Pet) or oneOf
182
- klass = PCPServerSDK::Models.const_get(type)
183
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
184
- end
185
- end
186
-
187
- # Returns the string representation of the object
188
- # @return [String] String presentation of the object
189
- def to_s
190
- to_hash.to_s
191
- end
192
-
193
- # to_body is an alias to to_hash (backward compatibility)
194
- # @return [Hash] Returns the object in the form of hash
195
- def to_body
196
- to_hash
197
- end
198
-
199
- # Returns the object in the form of hash
200
- # @return [Hash] Returns the object in the form of hash
201
- def to_hash
202
- hash = {}
203
- self.class.attribute_map.each_pair do |attr, param|
204
- value = self.send(attr)
205
- if value.nil?
206
- is_nullable = self.class.openapi_nullable.include?(attr)
207
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
208
- end
209
-
210
- hash[param] = _to_hash(value)
211
- end
212
- hash
213
- end
214
-
215
- # Outputs non-array value in the form of hash
216
- # For object, use to_hash. Otherwise, just return the value
217
- # @param [Object] value Any valid value
218
- # @return [Hash] Returns the value in the form of hash
219
- def _to_hash(value)
220
- if value.is_a?(Array)
221
- value.compact.map { |v| _to_hash(v) }
222
- elsif value.is_a?(Hash)
223
- {}.tap do |hash|
224
- value.each { |k, v| hash[k] = _to_hash(v) }
225
- end
226
- elsif value.respond_to? :to_hash
227
- value.to_hash
228
- else
229
- value
230
- end
231
- end
9
+ attribute :scheme_eci, :schemeEci, :String
10
+ # Exemption requested and applied in the authorization.
11
+ attribute :applied_exemption, :appliedExemption, :String, enum: ["low-value", "merchant-acquirer-transaction-risk-analysis"]
232
12
  end
233
13
  end
234
14
  end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module PCPServerSDK
3
- VERSION = '1.12.0'
3
+ VERSION = '1.13.0'
4
4
  end
@@ -6,6 +6,7 @@ require_relative 'PCP-server-Ruby-SDK/endpoints/commerce_case_api_client'
6
6
  require_relative 'PCP-server-Ruby-SDK/endpoints/order_management_checkout_actions_api_client'
7
7
  require_relative 'PCP-server-Ruby-SDK/endpoints/payment_execution_api_client'
8
8
  require_relative 'PCP-server-Ruby-SDK/endpoints/payment_information_api_client'
9
+ require_relative 'PCP-server-Ruby-SDK/endpoints/payment_intent_api_client'
9
10
 
10
11
  # Errors
11
12
  require_relative 'PCP-server-Ruby-SDK/errors/api_error_response_exception'
@@ -37,6 +38,7 @@ require_relative 'PCP-server-Ruby-SDK/models/capture_payment_request'
37
38
  require_relative 'PCP-server-Ruby-SDK/models/capture_payment_response'
38
39
  require_relative 'PCP-server-Ruby-SDK/models/card_fraud_results'
39
40
  require_relative 'PCP-server-Ruby-SDK/models/card_info'
41
+ require_relative 'PCP-server-Ruby-SDK/models/cart_item_data'
40
42
  require_relative 'PCP-server-Ruby-SDK/models/card_payment_details'
41
43
  require_relative 'PCP-server-Ruby-SDK/models/card_payment_method_specific_input'
42
44
  require_relative 'PCP-server-Ruby-SDK/models/card_payment_method_specific_output'
@@ -66,6 +68,7 @@ require_relative 'PCP-server-Ruby-SDK/models/create_commerce_case_request'
66
68
  require_relative 'PCP-server-Ruby-SDK/models/create_commerce_case_response'
67
69
  require_relative 'PCP-server-Ruby-SDK/models/create_payment_response'
68
70
  require_relative 'PCP-server-Ruby-SDK/models/customer'
71
+ require_relative 'PCP-server-Ruby-SDK/models/customer_account'
69
72
  require_relative 'PCP-server-Ruby-SDK/models/customer_device'
70
73
  require_relative 'PCP-server-Ruby-SDK/models/deliver_item'
71
74
  require_relative 'PCP-server-Ruby-SDK/models/deliver_request'
@@ -112,6 +115,19 @@ require_relative 'PCP-server-Ruby-SDK/models/payment_information_refund_response
112
115
  require_relative 'PCP-server-Ruby-SDK/models/payment_information_request'
113
116
  require_relative 'PCP-server-Ruby-SDK/models/payment_information_response'
114
117
  require_relative 'PCP-server-Ruby-SDK/models/payment_instructions'
118
+ require_relative 'PCP-server-Ruby-SDK/models/create_payment_intent'
119
+ require_relative 'PCP-server-Ruby-SDK/models/create_payment_intent_request'
120
+ require_relative 'PCP-server-Ruby-SDK/models/create_payment_intent_response'
121
+ require_relative 'PCP-server-Ruby-SDK/models/payment_intent_response_data'
122
+ require_relative 'PCP-server-Ruby-SDK/models/payment_intent_output'
123
+ require_relative 'PCP-server-Ruby-SDK/models/payment_intent_response'
124
+ require_relative 'PCP-server-Ruby-SDK/models/payment_method_specific_input_for_intent'
125
+ require_relative 'PCP-server-Ruby-SDK/models/payment_product840_specific_output_data'
126
+ require_relative 'PCP-server-Ruby-SDK/models/payment_product840_specific_output_for_intent'
127
+ require_relative 'PCP-server-Ruby-SDK/models/redirect_payment_method_specific_input_for_intent'
128
+ require_relative 'PCP-server-Ruby-SDK/models/redirect_payment_method_specific_output_for_create_intent'
129
+ require_relative 'PCP-server-Ruby-SDK/models/redirect_payment_method_specific_output_for_intent'
130
+ require_relative 'PCP-server-Ruby-SDK/models/redirect_payment_product840_specific_input_data'
115
131
  require_relative 'PCP-server-Ruby-SDK/models/payment_method_specific_input'
116
132
  require_relative 'PCP-server-Ruby-SDK/models/payment_output'
117
133
  require_relative 'PCP-server-Ruby-SDK/models/payment_product302_specific_input'
@@ -159,7 +175,9 @@ require_relative 'PCP-server-Ruby-SDK/models/sepa_direct_debit_payment_method_sp
159
175
  require_relative 'PCP-server-Ruby-SDK/models/sepa_direct_debit_payment_product771_specific_input'
160
176
  require_relative 'PCP-server-Ruby-SDK/models/sepa_transfer_payment_product_772_specific_input'
161
177
  require_relative 'PCP-server-Ruby-SDK/models/shipping'
178
+ require_relative 'PCP-server-Ruby-SDK/models/shipping_address'
162
179
  require_relative 'PCP-server-Ruby-SDK/models/shopping_cart_input'
180
+ require_relative 'PCP-server-Ruby-SDK/models/shopping_cart_data'
163
181
  require_relative 'PCP-server-Ruby-SDK/models/shopping_cart_patch'
164
182
  require_relative 'PCP-server-Ruby-SDK/models/shopping_cart_result'
165
183
  require_relative 'PCP-server-Ruby-SDK/models/status_category_value'
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pcp-serversdk-ruby",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pcp-serversdk-ruby",
9
- "version": "1.12.0",
9
+ "version": "1.13.0",
10
10
  "devDependencies": {
11
11
  "@commitlint/cli": "19.4.0",
12
12
  "@commitlint/config-conventional": "19.2.2",
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pcp-serversdk-ruby",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "type": "commonjs",
5
5
  "scripts": {
6
6
  "changelog": "conventional-changelog -i CHANGELOG.md -s --config ./changelog.config.js"
@@ -0,0 +1,128 @@
1
+ # Regenerates eligible object model files from `api-definition.yaml` as concise
2
+ # `ModelBase` subclasses. Use this after an API-definition update or when the
3
+ # generated model layer needs to be brought back to the shared ModelBase style.
4
+ #
5
+ # The script rewrites eligible files in `lib/PCP-server-Ruby-SDK/models`; it is
6
+ # not a read-only audit. It intentionally excludes `oneOf`/`anyOf` schemas and
7
+ # keeps direct Ruby inheritance for single-parent `allOf` schemas. Attribute
8
+ # names, types, defaults, enums, and inheritance are derived from the API
9
+ # definition, making it the source of truth. Output filenames follow the Ruby
10
+ # naming convention, with documented exceptions for legacy filenames.
11
+ # Referenced object, composed, and enum schemas remain model types; only plain
12
+ # primitive aliases are converted to their Ruby primitive type.
13
+ #
14
+ # Running it can overwrite manual edits to eligible model files. Run it from a
15
+ # clean or understood worktree, then inspect `git diff` and run the full test
16
+ # suite before committing. Do not use it to regenerate endpoint clients or
17
+ # special composed models; those require manual implementation and review.
18
+
19
+ require 'pathname'
20
+ require 'set'
21
+ require 'yaml'
22
+
23
+ ROOT = Pathname.new(__dir__).parent
24
+ MODELS_DIRECTORY = ROOT.join('lib/PCP-server-Ruby-SDK/models')
25
+ SCHEMAS = YAML.unsafe_load_file(ROOT.join('api-definition.yaml')).fetch('components').fetch('schemas')
26
+ PRIMITIVE_TYPES = {
27
+ 'string' => :String,
28
+ 'integer' => :Integer,
29
+ 'number' => :Float,
30
+ 'boolean' => :Boolean
31
+ }.freeze
32
+ MODEL_FILE_OVERRIDES = {
33
+ # These existing filenames do not follow the class-name conversion convention.
34
+ 'MobilePaymentThreeDSecure' => 'mobile_payment_three_dsecure.rb',
35
+ 'SepaTransferPaymentProduct772SpecificInput' => 'sepa_transfer_payment_product_772_specific_input.rb'
36
+ }.freeze
37
+
38
+ def direct_parent_name(schema)
39
+ parents = Array(schema['allOf']).filter_map { |item| item['$ref']&.split('/')&.last }
40
+ parents.first if parents.size == 1
41
+ end
42
+
43
+ def local_properties(schema)
44
+ schema.fetch('properties', {}).merge(Array(schema['allOf']).each_with_object({}) do |item, properties|
45
+ properties.merge!(item.fetch('properties', {})) unless item.key?('$ref')
46
+ end)
47
+ end
48
+
49
+ def snake_case(value)
50
+ value.gsub(/([A-Z\d]+)([A-Z][a-z])/, '\\1_\\2')
51
+ .gsub(/([a-z\d])([A-Z])/, '\\1_\\2')
52
+ .tr('-', '_')
53
+ .downcase
54
+ end
55
+
56
+ def model_file(class_name)
57
+ MODELS_DIRECTORY.join(MODEL_FILE_OVERRIDES.fetch(class_name, "#{snake_case(class_name)}.rb"))
58
+ end
59
+
60
+ def ruby_type(schema, resolving = Set.new)
61
+ if schema['$ref']
62
+ name = schema['$ref'].split('/').last
63
+ return name.to_sym if resolving.include?(name)
64
+
65
+ referenced_schema = SCHEMAS.fetch(name)
66
+ # Enum references have generated model classes that validate deserialized values.
67
+ return name.to_sym if referenced_schema['type'] == 'object' || referenced_schema.key?('oneOf') || referenced_schema.key?('anyOf') || referenced_schema.key?('enum')
68
+
69
+ return ruby_type(referenced_schema, resolving | [name])
70
+ end
71
+
72
+ return ruby_type(schema.fetch('allOf').first, resolving) if schema['allOf']&.size == 1
73
+ return "Array<#{ruby_type(schema.fetch('items'), resolving)}>" if schema['type'] == 'array'
74
+
75
+ if schema['type'] == 'object' && schema['additionalProperties']
76
+ return "Hash<String, #{ruby_type(schema.fetch('additionalProperties'), resolving)}>"
77
+ end
78
+
79
+ return :Date if schema['format'] == 'date'
80
+ return :Time if schema['format'] == 'date-time'
81
+
82
+ PRIMITIVE_TYPES.fetch(schema['type'], :Object)
83
+ end
84
+
85
+ def description_lines(description)
86
+ description.to_s.lines.map do |line|
87
+ line.strip.empty? ? ' #' : " # #{line.strip}"
88
+ end
89
+ end
90
+
91
+ def render_model(class_name, attributes, parent_name)
92
+ superclass = parent_name || 'ModelBase'
93
+ dependency = parent_name ? snake_case(parent_name) : 'model_base'
94
+ output = ["require_relative '#{dependency}'", '', 'module PCPServerSDK', ' module Models', " class #{class_name} < #{superclass}"]
95
+
96
+ attributes.each do |name, json_name, type, property|
97
+ options = []
98
+ options << "default: #{property['default'].inspect}" if property.key?('default')
99
+ options << "enum: #{property['enum'].inspect}" if property.key?('enum')
100
+ output.concat(description_lines(property['description'])) if property.key?('description')
101
+ output << " attribute #{name.inspect}, #{json_name.inspect}, #{type.inspect}#{", #{options.join(', ')}" unless options.empty?}"
102
+ end
103
+
104
+ if parent_name
105
+ output << '' unless attributes.empty?
106
+ output << ' def self.openapi_all_of'
107
+ output << " [#{parent_name.to_sym.inspect}]"
108
+ output << ' end'
109
+ end
110
+
111
+ output.concat([' end', ' end', 'end', ''])
112
+ output.join("\n")
113
+ end
114
+
115
+ eligible = SCHEMAS.select do |_name, schema|
116
+ schema['type'] == 'object' && !schema.key?('oneOf') && !schema.key?('anyOf')
117
+ end
118
+
119
+ metadata = eligible.transform_values do |schema|
120
+ attributes = local_properties(schema).map do |json_name, property|
121
+ [snake_case(json_name).to_sym, json_name.to_sym, ruby_type(property), property]
122
+ end
123
+ { attributes: attributes, parent_name: direct_parent_name(schema) }
124
+ end
125
+
126
+ metadata.sort.each do |class_name, model_metadata|
127
+ model_file(class_name).write(render_model(class_name, model_metadata.fetch(:attributes), model_metadata.fetch(:parent_name)))
128
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+ require_relative '../../lib/PCP-server-Ruby-SDK'
4
+
5
+ RSpec.describe PCPServerSDK::Endpoints::PaymentIntentApiClient do
6
+ let(:config) { mock_communicator_config }
7
+ let(:client) { described_class.new(config) }
8
+
9
+ describe '#create_payment_intent' do
10
+ it 'posts the payload and deserializes the response' do
11
+ payload = PCPServerSDK::Models::CreatePaymentIntentRequest.new
12
+ response = double('Response', body: '{"paymentIntentOutput":{"paymentIntentId":"intent-1"}}', code: '201')
13
+ allow(client).to receive(:get_response).and_return(response)
14
+
15
+ result = client.create_payment_intent('merchant-1', payload)
16
+
17
+ expect(result).to be_a(PCPServerSDK::Models::CreatePaymentIntentResponse)
18
+ expect(result.payment_intent_output.payment_intent_id).to eq('intent-1')
19
+ end
20
+
21
+ it 'validates the merchant ID and payload' do
22
+ expect { client.create_payment_intent(nil, {}) }.to raise_error(TypeError, 'Merchant ID is required')
23
+ expect { client.create_payment_intent('merchant-1', nil) }.to raise_error(TypeError, 'Payload is required')
24
+ end
25
+ end
26
+
27
+ describe '#get_payment_intent' do
28
+ it 'deserializes the response' do
29
+ response = double('Response', body: '{"paymentIntentId":"intent-1"}', code: '200')
30
+ allow(client).to receive(:get_response).and_return(response)
31
+
32
+ result = client.get_payment_intent('merchant-1', 'intent-1')
33
+
34
+ expect(result).to be_a(PCPServerSDK::Models::PaymentIntentResponse)
35
+ expect(result.payment_intent_id).to eq('intent-1')
36
+ end
37
+
38
+ it 'validates the merchant ID and payment intent ID' do
39
+ expect { client.get_payment_intent(nil, 'intent-1') }.to raise_error(TypeError, 'Merchant ID is required')
40
+ expect { client.get_payment_intent('merchant-1', nil) }.to raise_error(TypeError, 'Payment Intent ID is required')
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+ require 'yaml'
3
+ require_relative '../../lib/PCP-server-Ruby-SDK'
4
+
5
+ RSpec.describe 'OpenAPI model conformance' do
6
+ let(:schemas) { YAML.unsafe_load_file(File.expand_path('../../api-definition.yaml', __dir__))['components']['schemas'] }
7
+
8
+ def schema_properties(name)
9
+ schema_properties_from(schemas.fetch(name))
10
+ end
11
+
12
+ def schema_properties_from(schema)
13
+ inherited = Array(schema['allOf']).flat_map do |parent|
14
+ parent['$ref'] ? schema_properties(parent['$ref'].split('/').last) : schema_properties_from(parent)
15
+ end
16
+ inherited + schema.fetch('properties', {}).keys
17
+ end
18
+
19
+ it 'provides a model for every object schema' do
20
+ object_schemas = schemas.select { |_name, schema| schema['type'] == 'object' }.keys
21
+ missing = object_schemas.reject { |name| PCPServerSDK::Models.const_defined?(name, false) }
22
+
23
+ expect(missing).to be_empty
24
+ end
25
+
26
+ it 'uses ModelBase for every non-composed object schema' do
27
+ ineligible = schemas.select { |_name, schema| schema.key?('oneOf') || schema.key?('anyOf') }.keys
28
+ eligible = schemas.select { |name, schema| schema['type'] == 'object' && !ineligible.include?(name) }.keys
29
+ mismatches = eligible.reject { |name| PCPServerSDK::Models.const_get(name) <= PCPServerSDK::Models::ModelBase }
30
+
31
+ expect(mismatches).to be_empty
32
+ end
33
+
34
+ it 'maps every flattened schema property' do
35
+ mismatches = schemas.filter_map do |name, schema|
36
+ next unless schema['type'] == 'object'
37
+
38
+ model = PCPServerSDK::Models.const_get(name)
39
+ expected = schema_properties(name).sort
40
+ actual = model.attribute_map.values.map(&:to_s).sort
41
+ "#{name}: expected #{expected}, got #{actual}" unless actual == expected
42
+ end
43
+
44
+ expect(mismatches).to be_empty
45
+ end
46
+
47
+ it 'declares each direct allOf parent' do
48
+ mismatches = schemas.filter_map do |name, schema|
49
+ expected = Array(schema['allOf']).filter_map { |parent| parent['$ref']&.split('/')&.last }.sort
50
+ next if expected.empty?
51
+
52
+ model = PCPServerSDK::Models.const_get(name)
53
+ actual = model.respond_to?(:openapi_all_of) ? model.openapi_all_of.map(&:to_s).sort : []
54
+ "#{name}: expected #{expected}, got #{actual}" unless actual == expected
55
+ end
56
+
57
+ expect(mismatches).to be_empty
58
+ end
59
+
60
+ it 'uses each direct allOf parent as its Ruby superclass' do
61
+ mismatches = schemas.filter_map do |name, schema|
62
+ parents = Array(schema['allOf']).filter_map { |parent| parent['$ref']&.split('/')&.last }
63
+ next unless parents.size == 1
64
+
65
+ model = PCPServerSDK::Models.const_get(name)
66
+ parent = PCPServerSDK::Models.const_get(parents.first)
67
+ "#{name}: expected #{parent}, got #{model.superclass}" unless model.superclass == parent
68
+ end
69
+
70
+ expect(mismatches).to be_empty
71
+ end
72
+
73
+ it 'inherits parent attribute accessors instead of redeclaring them' do
74
+ mismatches = schemas.filter_map do |name, schema|
75
+ parents = Array(schema['allOf']).filter_map { |parent| parent['$ref']&.split('/')&.last }
76
+ next unless parents.size == 1
77
+
78
+ model = PCPServerSDK::Models.const_get(name)
79
+ parent = PCPServerSDK::Models.const_get(parents.first)
80
+ redeclared = parent.attribute_map.keys.select do |attribute|
81
+ model.instance_method(attribute).owner == model
82
+ end
83
+ "#{name}: redeclares #{redeclared}" unless redeclared.empty?
84
+ end
85
+
86
+ expect(mismatches).to be_empty
87
+ end
88
+ end
@@ -0,0 +1,87 @@
1
+ require 'spec_helper'
2
+ require_relative '../../lib/PCP-server-Ruby-SDK'
3
+
4
+ module PCPServerSDK
5
+ module Models
6
+ class ModelBaseSpecNestedModel < ModelBase
7
+ attribute :name, :name, :String
8
+ end
9
+
10
+ class ModelBaseSpecModel < ModelBase
11
+ attribute :name, :name, :String
12
+ attribute :enabled, :enabled, :Boolean
13
+ attribute :count, :count, :Integer
14
+ attribute :items, :items, 'Array<ModelBaseSpecNestedModel>'
15
+ attribute :metadata, :metadata, 'Hash<String, ModelBaseSpecNestedModel>'
16
+ attribute :nested, :nested, :ModelBaseSpecNestedModel
17
+ end
18
+
19
+ class ModelBaseSpecParentModel < ModelBase
20
+ attribute :enabled, :enabled, :Boolean, default: false
21
+ attribute :state, :state, :String, enum: ['ACTIVE']
22
+ end
23
+
24
+ class ModelBaseSpecChildModel < ModelBaseSpecParentModel
25
+ attribute :name, :name, :String
26
+ end
27
+ end
28
+ end
29
+
30
+ RSpec.describe PCPServerSDK::Models::ModelBase do
31
+ let(:model_class) { PCPServerSDK::Models::ModelBaseSpecModel }
32
+
33
+ it 'deserializes primitives, arrays, hashes, and nested models from JSON hashes' do
34
+ model = model_class.build_from_hash(
35
+ 'name' => 'model',
36
+ 'enabled' => 'false',
37
+ 'count' => '12',
38
+ 'items' => [{ 'name' => 'one' }],
39
+ 'metadata' => { 'first' => { 'name' => 'two' } },
40
+ 'nested' => { 'name' => 'three' }
41
+ )
42
+
43
+ expect(model.name).to eq('model')
44
+ expect(model.enabled).to be(false)
45
+ expect(model.count).to eq(12)
46
+ expect(model.items.first.name).to eq('one')
47
+ expect(model.metadata['first'].name).to eq('two')
48
+ expect(model.nested.name).to eq('three')
49
+ expect(model.to_hash).to eq(
50
+ name: 'model', enabled: false, count: 12,
51
+ items: [{ name: 'one' }], metadata: { 'first' => { name: 'two' } }, nested: { name: 'three' }
52
+ )
53
+ end
54
+
55
+ it 'preserves nil values from JSON hashes without serializing them' do
56
+ model = model_class.build_from_hash(
57
+ 'name' => nil,
58
+ 'items' => nil,
59
+ 'metadata' => nil,
60
+ 'nested' => nil
61
+ )
62
+
63
+ expect(model.name).to be_nil
64
+ expect(model.items).to be_nil
65
+ expect(model.metadata).to be_nil
66
+ expect(model.nested).to be_nil
67
+ expect(model.to_hash).to be_empty
68
+ end
69
+
70
+ it 'rejects unknown attributes and serializes only assigned values' do
71
+ expect { model_class.new(unknown: true) }.to raise_error(ArgumentError, '`unknown` is not a valid attribute')
72
+ expect(model_class.new(name: 'one').to_hash).to eq(name: 'one')
73
+ end
74
+
75
+ it 'drops nil entries from arrays during serialization' do
76
+ model = model_class.new(items: [nil, PCPServerSDK::Models::ModelBaseSpecNestedModel.new(name: 'one')])
77
+
78
+ expect(model.to_hash).to eq(items: [{ name: 'one' }])
79
+ end
80
+
81
+ it 'inherits defaults and enum validation' do
82
+ model = PCPServerSDK::Models::ModelBaseSpecChildModel.new(name: 'child')
83
+
84
+ expect(model.enabled).to be(false)
85
+ expect { model.state = 'INACTIVE' }.to raise_error(ArgumentError, 'invalid value for "state", must be one of ["ACTIVE"].')
86
+ end
87
+ end