pcp-server-ruby-sdk 1.6.0 → 1.8.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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/api-definition.yaml +5012 -4842
  4. data/lib/PCP-server-Ruby-SDK/models/apple_payment_data_token_header_information.rb +2 -0
  5. data/lib/PCP-server-Ruby-SDK/models/apple_payment_data_token_information.rb +6 -0
  6. data/lib/PCP-server-Ruby-SDK/models/bank_account_information.rb +0 -2
  7. data/lib/PCP-server-Ruby-SDK/models/bank_payout_method_specific_input.rb +0 -4
  8. data/lib/PCP-server-Ruby-SDK/models/cancel_payment_request.rb +8 -0
  9. data/lib/PCP-server-Ruby-SDK/models/capture_payment_request.rb +13 -4
  10. data/lib/PCP-server-Ruby-SDK/models/capture_payment_response.rb +13 -4
  11. data/lib/PCP-server-Ruby-SDK/models/cart_item_input.rb +13 -4
  12. data/lib/PCP-server-Ruby-SDK/models/cart_item_patch.rb +13 -4
  13. data/lib/PCP-server-Ruby-SDK/models/cart_item_result.rb +13 -4
  14. data/lib/PCP-server-Ruby-SDK/models/cart_item_supplier_references.rb +200 -0
  15. data/lib/PCP-server-Ruby-SDK/models/complete_order_request.rb +187 -0
  16. data/lib/PCP-server-Ruby-SDK/models/complete_payment_product840_specific_input.rb +2 -0
  17. data/lib/PCP-server-Ruby-SDK/models/create_payment_response.rb +13 -4
  18. data/lib/PCP-server-Ruby-SDK/models/deliver_request.rb +12 -4
  19. data/lib/PCP-server-Ruby-SDK/models/fund_distribution.rb +272 -0
  20. data/lib/PCP-server-Ruby-SDK/models/fund_split.rb +211 -0
  21. data/lib/PCP-server-Ruby-SDK/models/mobile_payment_method_specific_input.rb +13 -4
  22. data/lib/PCP-server-Ruby-SDK/models/mobile_payment_method_specific_output.rb +1 -1
  23. data/lib/PCP-server-Ruby-SDK/models/{network.rb → mobile_payment_network.rb} +4 -4
  24. data/lib/PCP-server-Ruby-SDK/models/order_line_details_input.rb +2 -1
  25. data/lib/PCP-server-Ruby-SDK/models/order_line_details_patch.rb +11 -1
  26. data/lib/PCP-server-Ruby-SDK/models/order_line_details_result.rb +11 -1
  27. data/lib/PCP-server-Ruby-SDK/models/order_request.rb +12 -4
  28. data/lib/PCP-server-Ruby-SDK/models/pause_payment_request.rb +5 -38
  29. data/lib/PCP-server-Ruby-SDK/models/payment_event.rb +34 -4
  30. data/lib/PCP-server-Ruby-SDK/models/payment_execution.rb +15 -4
  31. data/lib/PCP-server-Ruby-SDK/models/payment_execution_specific_input.rb +13 -4
  32. data/lib/PCP-server-Ruby-SDK/models/payment_product302_specific_input.rb +1 -1
  33. data/lib/PCP-server-Ruby-SDK/models/payment_product5002_specific_input.rb +209 -0
  34. data/lib/PCP-server-Ruby-SDK/models/payment_references_for_refund.rb +198 -0
  35. data/lib/PCP-server-Ruby-SDK/models/redirect_payment_method_specific_input.rb +4 -14
  36. data/lib/PCP-server-Ruby-SDK/models/redirect_payment_method_specific_output.rb +4 -14
  37. data/lib/PCP-server-Ruby-SDK/models/refund_payment_response.rb +12 -4
  38. data/lib/PCP-server-Ruby-SDK/models/refund_request.rb +14 -5
  39. data/lib/PCP-server-Ruby-SDK/models/return_request.rb +204 -191
  40. data/lib/PCP-server-Ruby-SDK/transformer/apple_pay_transformer.rb +2 -2
  41. data/lib/PCP-server-Ruby-SDK/version.rb +1 -1
  42. data/lib/PCP-server-Ruby-SDK.rb +7 -1
  43. data/package-lock.json +16 -3
  44. data/package.json +1 -1
  45. data/scripts.sh +2 -2
  46. data/spec/transformer/apple_pay_transformer_spec.rb +1 -1
  47. metadata +13 -7
@@ -0,0 +1,187 @@
1
+ require 'date'
2
+ require 'time'
3
+
4
+ # Request to complete an order.
5
+ module PCPServerSDK
6
+ module Models
7
+ class CompleteOrderRequest
8
+ attr_accessor :complete_payment_method_specific_input
9
+
10
+ # Attribute mapping from ruby-style variable name to JSON key.
11
+ def self.attribute_map
12
+ {
13
+ :'complete_payment_method_specific_input' => :'completePaymentMethodSpecificInput'
14
+ }
15
+ end
16
+
17
+ # Returns all the JSON keys this model knows about
18
+ def self.acceptable_attributes
19
+ attribute_map.values
20
+ end
21
+
22
+ # Attribute type mapping.
23
+ def self.openapi_types
24
+ {
25
+ :'complete_payment_method_specific_input' => :'CompletePaymentMethodSpecificInput'
26
+ }
27
+ end
28
+
29
+ # List of attributes with nullable: true
30
+ def self.openapi_nullable
31
+ Set.new([])
32
+ end
33
+
34
+ # Initializes the object
35
+ # @param [Hash] attributes Model attributes in the form of hash
36
+ def initialize(attributes = {})
37
+ if (!attributes.is_a?(Hash))
38
+ fail ArgumentError, "The input argument (attributes) must be a hash in `CompleteOrderRequest` initialize method"
39
+ end
40
+
41
+ # check to see if the attribute exists and convert string to symbol for hash key
42
+ attributes = attributes.each_with_object({}) { |(k, v), h|
43
+ if (!self.class.attribute_map.key?(k.to_sym))
44
+ fail ArgumentError, "`#{k}` is not a valid attribute in `CompleteOrderRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
45
+ end
46
+ h[k.to_sym] = v
47
+ }
48
+
49
+ if attributes.key?(:'complete_payment_method_specific_input')
50
+ self.complete_payment_method_specific_input = attributes[:'complete_payment_method_specific_input']
51
+ end
52
+ end
53
+
54
+ # Checks equality by comparing each attribute.
55
+ # @param [Object] Object to be compared
56
+ def ==(o)
57
+ return true if self.equal?(o)
58
+ self.class == o.class &&
59
+ complete_payment_method_specific_input == o.complete_payment_method_specific_input
60
+ end
61
+
62
+ # @see the `==` method
63
+ # @param [Object] Object to be compared
64
+ def eql?(o)
65
+ self == o
66
+ end
67
+
68
+ # Calculates hash code according to all attributes.
69
+ # @return [Integer] Hash code
70
+ def hash
71
+ [complete_payment_method_specific_input].hash
72
+ end
73
+
74
+ # Builds the object from hash
75
+ # @param [Hash] attributes Model attributes in the form of hash
76
+ # @return [Object] Returns the model itself
77
+ def self.build_from_hash(attributes)
78
+ return nil unless attributes.is_a?(Hash)
79
+ attributes = attributes.transform_keys(&:to_sym)
80
+ transformed_hash = {}
81
+ openapi_types.each_pair do |key, type|
82
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
83
+ transformed_hash["#{key}"] = nil
84
+ elsif type =~ /\AArray<(.*)>/i
85
+ # check to ensure the input is an array given that the attribute
86
+ # is documented as an array but the input is not
87
+ if attributes[attribute_map[key]].is_a?(Array)
88
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
89
+ end
90
+ elsif !attributes[attribute_map[key]].nil?
91
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
92
+ end
93
+ end
94
+ new(transformed_hash)
95
+ end
96
+
97
+ # Deserializes the data based on type
98
+ # @param string type Data type
99
+ # @param string value Value to be deserialized
100
+ # @return [Object] Deserialized data
101
+ def self._deserialize(type, value)
102
+ case type.to_sym
103
+ when :Time
104
+ Time.parse(value)
105
+ when :Date
106
+ Date.parse(value)
107
+ when :String
108
+ value.to_s
109
+ when :Integer
110
+ value.to_i
111
+ when :Float
112
+ value.to_f
113
+ when :Boolean
114
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
115
+ true
116
+ else
117
+ false
118
+ end
119
+ when :Object
120
+ # generic object (usually a Hash), return directly
121
+ value
122
+ when /\AArray<(?<inner_type>.+)>\z/
123
+ inner_type = Regexp.last_match[:inner_type]
124
+ value.map { |v| _deserialize(inner_type, v) }
125
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
126
+ k_type = Regexp.last_match[:k_type]
127
+ v_type = Regexp.last_match[:v_type]
128
+ {}.tap do |hash|
129
+ value.each do |k, v|
130
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
131
+ end
132
+ end
133
+ else # model
134
+ # models (e.g. Pet) or oneOf
135
+ klass = PCPServerSDK::Models.const_get(type)
136
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
137
+ end
138
+ end
139
+
140
+ # Returns the string representation of the object
141
+ # @return [String] String presentation of the object
142
+ def to_s
143
+ to_hash.to_s
144
+ end
145
+
146
+ # to_body is an alias to to_hash (backward compatibility)
147
+ # @return [Hash] Returns the object in the form of hash
148
+ def to_body
149
+ to_hash
150
+ end
151
+
152
+ # Returns the object in the form of hash
153
+ # @return [Hash] Returns the object in the form of hash
154
+ def to_hash
155
+ hash = {}
156
+ self.class.attribute_map.each_pair do |attr, param|
157
+ value = self.send(attr)
158
+ if value.nil?
159
+ is_nullable = self.class.openapi_nullable.include?(attr)
160
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
161
+ end
162
+
163
+ hash[param] = _to_hash(value)
164
+ end
165
+ hash
166
+ end
167
+
168
+ # Outputs non-array value in the form of hash
169
+ # For object, use to_hash. Otherwise, just return the value
170
+ # @param [Object] value Any valid value
171
+ # @return [Hash] Returns the value in the form of hash
172
+ def _to_hash(value)
173
+ if value.is_a?(Array)
174
+ value.compact.map { |v| _to_hash(v) }
175
+ elsif value.is_a?(Hash)
176
+ {}.tap do |hash|
177
+ value.each { |k, v| hash[k] = _to_hash(v) }
178
+ end
179
+ elsif value.respond_to? :to_hash
180
+ value.to_hash
181
+ else
182
+ value
183
+ end
184
+ end
185
+ end
186
+ end
187
+ end
@@ -82,6 +82,8 @@ module PCPServerSDK
82
82
 
83
83
  if attributes.key?(:'action')
84
84
  self.action = attributes[:'action']
85
+ else
86
+ self.action = nil
85
87
  end
86
88
  end
87
89
 
@@ -14,13 +14,16 @@ module PCPServerSDK
14
14
  # reference to the paymentExecution.
15
15
  attr_accessor :payment_execution_id
16
16
 
17
+ attr_accessor :fund_split
18
+
17
19
  # Attribute mapping from ruby-style variable name to JSON key.
18
20
  def self.attribute_map
19
21
  {
20
22
  :'creation_output' => :'creationOutput',
21
23
  :'merchant_action' => :'merchantAction',
22
24
  :'payment' => :'payment',
23
- :'payment_execution_id' => :'paymentExecutionId'
25
+ :'payment_execution_id' => :'paymentExecutionId',
26
+ :'fund_split' => :'fundSplit'
24
27
  }
25
28
  end
26
29
 
@@ -35,7 +38,8 @@ module PCPServerSDK
35
38
  :'creation_output' => :'PaymentCreationOutput',
36
39
  :'merchant_action' => :'MerchantAction',
37
40
  :'payment' => :'PaymentResponse',
38
- :'payment_execution_id' => :'String'
41
+ :'payment_execution_id' => :'String',
42
+ :'fund_split' => :'FundSplit'
39
43
  }
40
44
  end
41
45
 
@@ -75,6 +79,10 @@ module PCPServerSDK
75
79
  if attributes.key?(:'payment_execution_id')
76
80
  self.payment_execution_id = attributes[:'payment_execution_id']
77
81
  end
82
+
83
+ if attributes.key?(:'fund_split')
84
+ self.fund_split = attributes[:'fund_split']
85
+ end
78
86
  end
79
87
 
80
88
  # Checks equality by comparing each attribute.
@@ -85,7 +93,8 @@ module PCPServerSDK
85
93
  creation_output == o.creation_output &&
86
94
  merchant_action == o.merchant_action &&
87
95
  payment == o.payment &&
88
- payment_execution_id == o.payment_execution_id
96
+ payment_execution_id == o.payment_execution_id &&
97
+ fund_split == o.fund_split
89
98
  end
90
99
 
91
100
  # @see the `==` method
@@ -97,7 +106,7 @@ module PCPServerSDK
97
106
  # Calculates hash code according to all attributes.
98
107
  # @return [Integer] Hash code
99
108
  def hash
100
- [creation_output, merchant_action, payment, payment_execution_id].hash
109
+ [creation_output, merchant_action, payment, payment_execution_id, fund_split].hash
101
110
  end
102
111
 
103
112
  # Builds the object from hash
@@ -15,6 +15,7 @@ module PCPServerSDK
15
15
 
16
16
  attr_accessor :deliver_items
17
17
 
18
+ attr_accessor :fund_split
18
19
 
19
20
  class EnumAttributeValidator
20
21
  attr_reader :datatype
@@ -44,7 +45,8 @@ module PCPServerSDK
44
45
  :'deliver_type' => :'deliverType',
45
46
  :'is_final' => :'isFinal',
46
47
  :'cancellation_reason' => :'cancellationReason',
47
- :'deliver_items' => :'deliverItems'
48
+ :'deliver_items' => :'deliverItems',
49
+ :'fund_split' => :'fundSplit'
48
50
  }
49
51
  end
50
52
 
@@ -59,7 +61,8 @@ module PCPServerSDK
59
61
  :'deliver_type' => :'DeliverType',
60
62
  :'is_final' => :'Boolean',
61
63
  :'cancellation_reason' => :'CancellationReason',
62
- :'deliver_items' => :'Array<DeliverItem>'
64
+ :'deliver_items' => :'Array<DeliverItem>',
65
+ :'fund_split' => :'FundSplit'
63
66
  }
64
67
  end
65
68
 
@@ -103,6 +106,10 @@ module PCPServerSDK
103
106
  self.deliver_items = value
104
107
  end
105
108
  end
109
+
110
+ if attributes.key?(:'fund_split')
111
+ self.fund_split = attributes[:'fund_split']
112
+ end
106
113
  end
107
114
 
108
115
  # Checks equality by comparing each attribute.
@@ -113,7 +120,8 @@ module PCPServerSDK
113
120
  deliver_type == o.deliver_type &&
114
121
  is_final == o.is_final &&
115
122
  cancellation_reason == o.cancellation_reason &&
116
- deliver_items == o.deliver_items
123
+ deliver_items == o.deliver_items &&
124
+ fund_split == o.fund_split
117
125
  end
118
126
 
119
127
  # @see the `==` method
@@ -125,7 +133,7 @@ module PCPServerSDK
125
133
  # Calculates hash code according to all attributes.
126
134
  # @return [Integer] Hash code
127
135
  def hash
128
- [deliver_type, is_final, cancellation_reason, deliver_items].hash
136
+ [deliver_type, is_final, cancellation_reason, deliver_items, fund_split].hash
129
137
  end
130
138
 
131
139
  # Builds the object from hash
@@ -0,0 +1,272 @@
1
+
2
+ require 'date'
3
+ require 'time'
4
+
5
+ module PCPServerSDK
6
+ module Models
7
+ # Instructions for distributing funds to multiple sellers or partners in a marketplace context.
8
+ class FundDistribution
9
+ # Unique ID of the fund distribution (read-only).
10
+ attr_accessor :id
11
+
12
+ # Unique identifier of the beneficiary (seller/partner/sub-account) to receive funds (e.g., payout account ID).
13
+ attr_accessor :account_id
14
+
15
+ # Human-readable description for reconciliation. Appears on reports.
16
+ attr_accessor :description
17
+
18
+ # Amount in cents and always having 2 decimals, in the currency of the original transaction.
19
+ attr_accessor :amount
20
+
21
+ # Classification or purpose of the fund distribution to the receiving account within a given order.
22
+ attr_accessor :type
23
+
24
+ # Unique reference of the part of the fund/payment to be distributed.
25
+ attr_accessor :merchant_reference
26
+
27
+ # Additional parameters for the transaction in JSON format.
28
+ attr_accessor :merchant_parameters
29
+
30
+ class EnumAttributeValidator
31
+ attr_reader :datatype
32
+ attr_reader :allowable_values
33
+
34
+ def initialize(datatype, allowable_values)
35
+ @allowable_values = allowable_values.map do |value|
36
+ case datatype.to_s
37
+ when /Integer/i
38
+ value.to_i
39
+ when /Float/i
40
+ value.to_f
41
+ else
42
+ value
43
+ end
44
+ end
45
+ end
46
+
47
+ def valid?(value)
48
+ !value || allowable_values.include?(value)
49
+ end
50
+ end
51
+
52
+ # Attribute mapping from ruby-style variable name to JSON key.
53
+ def self.attribute_map
54
+ {
55
+ :'id' => :'id',
56
+ :'account_id' => :'accountId',
57
+ :'description' => :'description',
58
+ :'amount' => :'amount',
59
+ :'type' => :'type',
60
+ :'merchant_reference' => :'merchantReference',
61
+ :'merchant_parameters' => :'merchantParameters'
62
+ }
63
+ end
64
+
65
+ # Returns all the JSON keys this model knows about
66
+ def self.acceptable_attributes
67
+ attribute_map.values
68
+ end
69
+
70
+ # Attribute type mapping.
71
+ def self.openapi_types
72
+ {
73
+ :'id' => :'String',
74
+ :'account_id' => :'String',
75
+ :'description' => :'String',
76
+ :'amount' => :'Integer',
77
+ :'type' => :'String',
78
+ :'merchant_reference' => :'String',
79
+ :'merchant_parameters' => :'String'
80
+ }
81
+ end
82
+
83
+ # List of attributes with nullable: true
84
+ def self.openapi_nullable
85
+ Set.new([
86
+ ])
87
+ end
88
+
89
+ # Initializes the object
90
+ # @param [Hash] attributes Model attributes in the form of hash
91
+ def initialize(attributes = {})
92
+ if (!attributes.is_a?(Hash))
93
+ fail ArgumentError, "The input argument (attributes) must be a hash in `FundDistribution` initialize method"
94
+ end
95
+
96
+ # check to see if the attribute exists and convert string to symbol for hash key
97
+ attributes = attributes.each_with_object({}) { |(k, v), h|
98
+ if (!self.class.attribute_map.key?(k.to_sym))
99
+ fail ArgumentError, "`#{k}` is not a valid attribute in `FundDistribution`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
100
+ end
101
+ h[k.to_sym] = v
102
+ }
103
+
104
+ if attributes.key?(:'id')
105
+ self.id = attributes[:'id']
106
+ end
107
+
108
+ if attributes.key?(:'account_id')
109
+ self.account_id = attributes[:'account_id']
110
+ end
111
+
112
+ if attributes.key?(:'description')
113
+ self.description = attributes[:'description']
114
+ end
115
+
116
+ if attributes.key?(:'amount')
117
+ self.amount = attributes[:'amount']
118
+ end
119
+
120
+ if attributes.key?(:'type')
121
+ self.type = attributes[:'type']
122
+ end
123
+
124
+ if attributes.key?(:'merchant_reference')
125
+ self.merchant_reference = attributes[:'merchant_reference']
126
+ end
127
+
128
+ if attributes.key?(:'merchant_parameters')
129
+ self.merchant_parameters = attributes[:'merchant_parameters']
130
+ end
131
+ end
132
+
133
+ # Checks equality by comparing each attribute.
134
+ # @param [Object] Object to be compared
135
+ def ==(o)
136
+ return true if self.equal?(o)
137
+ self.class == o.class &&
138
+ id == o.id &&
139
+ account_id == o.account_id &&
140
+ description == o.description &&
141
+ amount == o.amount &&
142
+ type == o.type &&
143
+ merchant_reference == o.merchant_reference &&
144
+ merchant_parameters == o.merchant_parameters
145
+ end
146
+
147
+ # @see the `==` method
148
+ # @param [Object] Object to be compared
149
+ def eql?(o)
150
+ self == o
151
+ end
152
+
153
+ # Calculates hash code according to all attributes.
154
+ # @return [Integer] Hash code
155
+ def hash
156
+ [id, account_id, description, amount, type, merchant_reference, merchant_parameters].hash
157
+ end
158
+
159
+ # Builds the object from hash
160
+ # @param [Hash] attributes Model attributes in the form of hash
161
+ # @return [Object] Returns the model itself
162
+ def self.build_from_hash(attributes)
163
+ return nil unless attributes.is_a?(Hash)
164
+ attributes = attributes.transform_keys(&:to_sym)
165
+ transformed_hash = {}
166
+ openapi_types.each_pair do |key, type|
167
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
168
+ transformed_hash["#{key}"] = nil
169
+ elsif type =~ /\AArray<(.*)>/i
170
+ # check to ensure the input is an array given that the attribute
171
+ # is documented as an array but the input is not
172
+ if attributes[attribute_map[key]].is_a?(Array)
173
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
174
+ end
175
+ elsif !attributes[attribute_map[key]].nil?
176
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
177
+ end
178
+ end
179
+ new(transformed_hash)
180
+ end
181
+
182
+ # Deserializes the data based on type
183
+ # @param string type Data type
184
+ # @param string value Value to be deserialized
185
+ # @return [Object] Deserialized data
186
+ def self._deserialize(type, value)
187
+ case type.to_sym
188
+ when :Time
189
+ Time.parse(value)
190
+ when :Date
191
+ Date.parse(value)
192
+ when :String
193
+ value.to_s
194
+ when :Integer
195
+ value.to_i
196
+ when :Float
197
+ value.to_f
198
+ when :Boolean
199
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
200
+ true
201
+ else
202
+ false
203
+ end
204
+ when :Object
205
+ # generic object (usually a Hash), return directly
206
+ value
207
+ when /\AArray<(?<inner_type>.+)>\z/
208
+ inner_type = Regexp.last_match[:inner_type]
209
+ value.map { |v| _deserialize(inner_type, v) }
210
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
211
+ k_type = Regexp.last_match[:k_type]
212
+ v_type = Regexp.last_match[:v_type]
213
+ {}.tap do |hash|
214
+ value.each do |k, v|
215
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
216
+ end
217
+ end
218
+ else # model
219
+ # models (e.g. Pet) or oneOf
220
+ klass = PCPServerSDK::Models.const_get(type)
221
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
222
+ end
223
+ end
224
+
225
+ # Returns the string representation of the object
226
+ # @return [String] String presentation of the object
227
+ def to_s
228
+ to_hash.to_s
229
+ end
230
+
231
+ # to_body is an alias to to_hash (backward compatibility)
232
+ # @return [Hash] Returns the object in the form of hash
233
+ def to_body
234
+ to_hash
235
+ end
236
+
237
+ # Returns the object in the form of hash
238
+ # @return [Hash] Returns the object in the form of hash
239
+ def to_hash
240
+ hash = {}
241
+ self.class.attribute_map.each_pair do |attr, param|
242
+ value = self.send(attr)
243
+ if value.nil?
244
+ is_nullable = self.class.openapi_nullable.include?(attr)
245
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
246
+ end
247
+
248
+ hash[param] = _to_hash(value)
249
+ end
250
+ hash
251
+ end
252
+
253
+ # Outputs non-array value in the form of hash
254
+ # For object, use to_hash. Otherwise, just return the value
255
+ # @param [Object] value Any valid value
256
+ # @return [Hash] Returns the value in the form of hash
257
+ def _to_hash(value)
258
+ if value.is_a?(Array)
259
+ value.compact.map { |v| _to_hash(v) }
260
+ elsif value.is_a?(Hash)
261
+ {}.tap do |hash|
262
+ value.each { |k, v| hash[k] = _to_hash(v) }
263
+ end
264
+ elsif value.respond_to? :to_hash
265
+ value.to_hash
266
+ else
267
+ value
268
+ end
269
+ end
270
+ end
271
+ end
272
+ end