tremendous_ruby 5.0.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tremendous/api/tremendous_api.rb +2365 -0
  3. data/lib/tremendous/api_client.rb +431 -0
  4. data/lib/tremendous/api_error.rb +58 -0
  5. data/lib/tremendous/configuration.rb +389 -0
  6. data/lib/tremendous/models/balance_transaction.rb +256 -0
  7. data/lib/tremendous/models/campaign.rb +292 -0
  8. data/lib/tremendous/models/create_api_key200_response.rb +215 -0
  9. data/lib/tremendous/models/create_invoice.rb +244 -0
  10. data/lib/tremendous/models/create_invoice200_response.rb +221 -0
  11. data/lib/tremendous/models/create_invoice_request.rb +244 -0
  12. data/lib/tremendous/models/create_member.rb +290 -0
  13. data/lib/tremendous/models/create_member200_response.rb +221 -0
  14. data/lib/tremendous/models/create_member_request.rb +290 -0
  15. data/lib/tremendous/models/create_order200_response.rb +221 -0
  16. data/lib/tremendous/models/create_order200_response_order.rb +400 -0
  17. data/lib/tremendous/models/create_order200_response_order_rewards_inner.rb +347 -0
  18. data/lib/tremendous/models/create_order200_response_order_rewards_inner_delivery.rb +296 -0
  19. data/lib/tremendous/models/create_order201_response.rb +221 -0
  20. data/lib/tremendous/models/create_order_request.rb +248 -0
  21. data/lib/tremendous/models/create_order_request_payment.rb +222 -0
  22. data/lib/tremendous/models/create_order_request_reward.rb +344 -0
  23. data/lib/tremendous/models/create_order_request_reward_delivery.rb +250 -0
  24. data/lib/tremendous/models/create_organization.rb +268 -0
  25. data/lib/tremendous/models/create_organization200_response.rb +214 -0
  26. data/lib/tremendous/models/create_organization200_response_organization.rb +334 -0
  27. data/lib/tremendous/models/create_organization_request.rb +268 -0
  28. data/lib/tremendous/models/create_organization_request_copy_settings.rb +278 -0
  29. data/lib/tremendous/models/create_webhook200_response.rb +214 -0
  30. data/lib/tremendous/models/create_webhook_request.rb +222 -0
  31. data/lib/tremendous/models/currency_codes.rb +154 -0
  32. data/lib/tremendous/models/custom_field.rb +248 -0
  33. data/lib/tremendous/models/delivery_details.rb +286 -0
  34. data/lib/tremendous/models/delivery_details_with_link.rb +296 -0
  35. data/lib/tremendous/models/delivery_method.rb +41 -0
  36. data/lib/tremendous/models/delivery_status.rb +42 -0
  37. data/lib/tremendous/models/error_model.rb +221 -0
  38. data/lib/tremendous/models/field.rb +286 -0
  39. data/lib/tremendous/models/funding_source.rb +332 -0
  40. data/lib/tremendous/models/generate_reward_link200_response.rb +221 -0
  41. data/lib/tremendous/models/generate_reward_link200_response_reward.rb +247 -0
  42. data/lib/tremendous/models/generate_reward_link403_response.rb +221 -0
  43. data/lib/tremendous/models/generate_reward_token200_response.rb +221 -0
  44. data/lib/tremendous/models/generate_reward_token200_response_reward.rb +257 -0
  45. data/lib/tremendous/models/get_campaign200_response.rb +221 -0
  46. data/lib/tremendous/models/get_funding_source200_response.rb +221 -0
  47. data/lib/tremendous/models/get_member200_response.rb +221 -0
  48. data/lib/tremendous/models/get_member200_response_member.rb +365 -0
  49. data/lib/tremendous/models/get_member200_response_member_events_inner.rb +260 -0
  50. data/lib/tremendous/models/get_organization200_response.rb +214 -0
  51. data/lib/tremendous/models/get_product200_response.rb +221 -0
  52. data/lib/tremendous/models/get_product_response.rb +221 -0
  53. data/lib/tremendous/models/get_reward200_response.rb +221 -0
  54. data/lib/tremendous/models/invoice.rb +356 -0
  55. data/lib/tremendous/models/list_balance_transactions200_response.rb +216 -0
  56. data/lib/tremendous/models/list_balance_transactions200_response_invoices_inner.rb +256 -0
  57. data/lib/tremendous/models/list_campaigns200_response.rb +223 -0
  58. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner.rb +292 -0
  59. data/lib/tremendous/models/list_fields200_response.rb +216 -0
  60. data/lib/tremendous/models/list_fields200_response_fields_inner.rb +286 -0
  61. data/lib/tremendous/models/list_funding_sources200_response.rb +223 -0
  62. data/lib/tremendous/models/list_funding_sources200_response_funding_sources_inner.rb +332 -0
  63. data/lib/tremendous/models/list_funding_sources200_response_funding_sources_inner_meta.rb +436 -0
  64. data/lib/tremendous/models/list_invoices200_response.rb +240 -0
  65. data/lib/tremendous/models/list_invoices200_response_invoices_inner.rb +356 -0
  66. data/lib/tremendous/models/list_members200_response.rb +223 -0
  67. data/lib/tremendous/models/list_members200_response_members_inner.rb +374 -0
  68. data/lib/tremendous/models/list_orders200_response.rb +240 -0
  69. data/lib/tremendous/models/list_orders200_response_orders_inner.rb +379 -0
  70. data/lib/tremendous/models/list_orders200_response_orders_inner_payment.rb +346 -0
  71. data/lib/tremendous/models/list_orders200_response_orders_inner_payment_refund.rb +242 -0
  72. data/lib/tremendous/models/list_organizations200_response.rb +216 -0
  73. data/lib/tremendous/models/list_organizations200_response_organizations_inner.rb +324 -0
  74. data/lib/tremendous/models/list_products200_response.rb +223 -0
  75. data/lib/tremendous/models/list_products200_response_products_inner.rb +457 -0
  76. data/lib/tremendous/models/list_products200_response_products_inner_countries_inner.rb +222 -0
  77. data/lib/tremendous/models/list_products200_response_products_inner_images_inner.rb +273 -0
  78. data/lib/tremendous/models/list_products200_response_products_inner_skus_inner.rb +277 -0
  79. data/lib/tremendous/models/list_products_response.rb +223 -0
  80. data/lib/tremendous/models/list_products_response_products_inner.rb +457 -0
  81. data/lib/tremendous/models/list_products_response_products_inner_countries_inner.rb +222 -0
  82. data/lib/tremendous/models/list_products_response_products_inner_images_inner.rb +273 -0
  83. data/lib/tremendous/models/list_products_response_products_inner_skus_inner.rb +277 -0
  84. data/lib/tremendous/models/list_rewards200_response.rb +226 -0
  85. data/lib/tremendous/models/list_rewards200_response_rewards_inner.rb +347 -0
  86. data/lib/tremendous/models/list_rewards200_response_rewards_inner_custom_fields_inner.rb +248 -0
  87. data/lib/tremendous/models/list_rewards200_response_rewards_inner_delivery.rb +286 -0
  88. data/lib/tremendous/models/list_rewards200_response_rewards_inner_recipient.rb +236 -0
  89. data/lib/tremendous/models/list_rewards200_response_rewards_inner_value.rb +273 -0
  90. data/lib/tremendous/models/list_rewards401_response.rb +221 -0
  91. data/lib/tremendous/models/list_rewards401_response_errors.rb +225 -0
  92. data/lib/tremendous/models/list_rewards429_response.rb +221 -0
  93. data/lib/tremendous/models/list_webhook_events200_response.rb +216 -0
  94. data/lib/tremendous/models/list_webhooks200_response.rb +216 -0
  95. data/lib/tremendous/models/list_webhooks200_response_webhooks_inner.rb +258 -0
  96. data/lib/tremendous/models/member.rb +374 -0
  97. data/lib/tremendous/models/member_base.rb +353 -0
  98. data/lib/tremendous/models/member_with_events.rb +365 -0
  99. data/lib/tremendous/models/member_without_events.rb +374 -0
  100. data/lib/tremendous/models/order.rb +379 -0
  101. data/lib/tremendous/models/order_base.rb +370 -0
  102. data/lib/tremendous/models/order_base_payment.rb +346 -0
  103. data/lib/tremendous/models/order_for_create.rb +248 -0
  104. data/lib/tremendous/models/order_for_create_reward.rb +416 -0
  105. data/lib/tremendous/models/order_status.rb +44 -0
  106. data/lib/tremendous/models/order_with_link.rb +400 -0
  107. data/lib/tremendous/models/order_with_link_rewards_inner.rb +406 -0
  108. data/lib/tremendous/models/order_without_link.rb +379 -0
  109. data/lib/tremendous/models/order_without_link_reward.rb +406 -0
  110. data/lib/tremendous/models/organization.rb +324 -0
  111. data/lib/tremendous/models/payment_details.rb +345 -0
  112. data/lib/tremendous/models/payment_details_refund.rb +242 -0
  113. data/lib/tremendous/models/product.rb +457 -0
  114. data/lib/tremendous/models/recipient.rb +236 -0
  115. data/lib/tremendous/models/refund_details.rb +241 -0
  116. data/lib/tremendous/models/resend_reward422_response.rb +221 -0
  117. data/lib/tremendous/models/reward.rb +406 -0
  118. data/lib/tremendous/models/reward_base.rb +397 -0
  119. data/lib/tremendous/models/reward_base_custom_fields_inner.rb +248 -0
  120. data/lib/tremendous/models/reward_for_order_create.rb +416 -0
  121. data/lib/tremendous/models/reward_link.rb +247 -0
  122. data/lib/tremendous/models/reward_token.rb +257 -0
  123. data/lib/tremendous/models/reward_value.rb +273 -0
  124. data/lib/tremendous/models/reward_with_link.rb +406 -0
  125. data/lib/tremendous/models/reward_with_link_delivery.rb +296 -0
  126. data/lib/tremendous/models/reward_without_link.rb +406 -0
  127. data/lib/tremendous/models/reward_without_link_delivery.rb +286 -0
  128. data/lib/tremendous/models/simulate_webhook_request.rb +222 -0
  129. data/lib/tremendous/models/webhook.rb +258 -0
  130. data/lib/tremendous/models/webhook_post.rb +222 -0
  131. data/lib/tremendous/version.rb +3 -0
  132. data/lib/tremendous.rb +159 -0
  133. metadata +133 -10
  134. data/spec/integration/campaigns_spec.rb +0 -27
  135. data/spec/integration/funding_sources_spec.rb +0 -18
  136. data/spec/integration/invoices_spec.rb +0 -19
  137. data/spec/integration/members_spec.rb +0 -19
  138. data/spec/integration/orders_spec.rb +0 -53
  139. data/spec/integration/products_spec.rb +0 -26
  140. data/spec/spec_helper.rb +0 -111
  141. data/spec/support/setup.rb +0 -10
@@ -0,0 +1,379 @@
1
+ =begin
2
+ #API Endpoints
3
+
4
+ #Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API.
5
+
6
+ The version of the OpenAPI document: 2
7
+ Contact: developers@tremendous.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.3.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Tremendous
17
+ # An order wraps around the fulfilment of one or more rewards.
18
+ class ListOrders200ResponseOrdersInner
19
+ # Tremendous ID of the order
20
+ attr_accessor :id
21
+
22
+ # Reference for this order, supplied by the customer. When set, `external_id` makes order idempotent. All requests that use the same `external_id` after the initial order creation, will result in a response that returns the data of the initially created order. The response will have a `201` response code. These responses **fail** to create any further orders. It also allows for retrieving by `external_id` instead of `id` only.
23
+ attr_accessor :external_id
24
+
25
+ # ID of the campaign in your account, that defines the available products (different gift cards, charity, etc.) that the recipient can choose from.
26
+ attr_accessor :campaign_id
27
+
28
+ # Date the order has been created
29
+ attr_accessor :created_at
30
+
31
+ # Execution status of a given order <table> <thead> <tr> <th> Status </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <code> CANCELED </code> </td> <td> The order and all of its rewards were canceled. </td> </tr> <tr> <td> <code> CART </code> </td> <td> The order has been created, but hasn't yet been processed. </td> </tr> <tr> <td> <code> EXECUTED </code> </td> <td> The order has been executed. Payment has been handled and rewards are being delivered (if applicable). </td> </tr> <tr> <td> <code> FAILED </code> </td> <td> The order could not be processed due to an error. E.g. due to insufficient funds in the account. </td> </tr> <tr> <td> <code> PENDING APPROVAL </code> </td> <td> The order has been created but needs approval to be executed. </td> </tr> <tr> <td> <code> PENDING INTERNAL PAYMENT APPROVAL </code> </td> <td> The order has been created but it is under review and requires approval from our team. </td> </tr> </tbody> </table>
32
+ attr_accessor :status
33
+
34
+ attr_accessor :payment
35
+
36
+ # The ID for the invoice associated with this order
37
+ attr_accessor :invoice_id
38
+
39
+ attr_accessor :reward
40
+
41
+ class EnumAttributeValidator
42
+ attr_reader :datatype
43
+ attr_reader :allowable_values
44
+
45
+ def initialize(datatype, allowable_values)
46
+ @allowable_values = allowable_values.map do |value|
47
+ case datatype.to_s
48
+ when /Integer/i
49
+ value.to_i
50
+ when /Float/i
51
+ value.to_f
52
+ else
53
+ value
54
+ end
55
+ end
56
+ end
57
+
58
+ def valid?(value)
59
+ !value || allowable_values.include?(value)
60
+ end
61
+ end
62
+
63
+ # Attribute mapping from ruby-style variable name to JSON key.
64
+ def self.attribute_map
65
+ {
66
+ :'id' => :'id',
67
+ :'external_id' => :'external_id',
68
+ :'campaign_id' => :'campaign_id',
69
+ :'created_at' => :'created_at',
70
+ :'status' => :'status',
71
+ :'payment' => :'payment',
72
+ :'invoice_id' => :'invoice_id',
73
+ :'reward' => :'reward'
74
+ }
75
+ end
76
+
77
+ # Returns all the JSON keys this model knows about
78
+ def self.acceptable_attributes
79
+ attribute_map.values
80
+ end
81
+
82
+ # Attribute type mapping.
83
+ def self.openapi_types
84
+ {
85
+ :'id' => :'String',
86
+ :'external_id' => :'String',
87
+ :'campaign_id' => :'String',
88
+ :'created_at' => :'Time',
89
+ :'status' => :'String',
90
+ :'payment' => :'ListOrders200ResponseOrdersInnerPayment',
91
+ :'invoice_id' => :'String',
92
+ :'reward' => :'ListRewards200ResponseRewardsInner'
93
+ }
94
+ end
95
+
96
+ # List of attributes with nullable: true
97
+ def self.openapi_nullable
98
+ Set.new([
99
+ :'external_id',
100
+ :'campaign_id',
101
+ ])
102
+ end
103
+
104
+ # Initializes the object
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ def initialize(attributes = {})
107
+ if (!attributes.is_a?(Hash))
108
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::ListOrders200ResponseOrdersInner` initialize method"
109
+ end
110
+
111
+ # check to see if the attribute exists and convert string to symbol for hash key
112
+ attributes = attributes.each_with_object({}) { |(k, v), h|
113
+ if (!self.class.attribute_map.key?(k.to_sym))
114
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::ListOrders200ResponseOrdersInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
115
+ end
116
+ h[k.to_sym] = v
117
+ }
118
+
119
+ if attributes.key?(:'id')
120
+ self.id = attributes[:'id']
121
+ else
122
+ self.id = nil
123
+ end
124
+
125
+ if attributes.key?(:'external_id')
126
+ self.external_id = attributes[:'external_id']
127
+ end
128
+
129
+ if attributes.key?(:'campaign_id')
130
+ self.campaign_id = attributes[:'campaign_id']
131
+ end
132
+
133
+ if attributes.key?(:'created_at')
134
+ self.created_at = attributes[:'created_at']
135
+ else
136
+ self.created_at = nil
137
+ end
138
+
139
+ if attributes.key?(:'status')
140
+ self.status = attributes[:'status']
141
+ else
142
+ self.status = nil
143
+ end
144
+
145
+ if attributes.key?(:'payment')
146
+ self.payment = attributes[:'payment']
147
+ end
148
+
149
+ if attributes.key?(:'invoice_id')
150
+ self.invoice_id = attributes[:'invoice_id']
151
+ end
152
+
153
+ if attributes.key?(:'reward')
154
+ self.reward = attributes[:'reward']
155
+ end
156
+ end
157
+
158
+ # Show invalid properties with the reasons. Usually used together with valid?
159
+ # @return Array for valid properties with the reasons
160
+ def list_invalid_properties
161
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
162
+ invalid_properties = Array.new
163
+ if @id.nil?
164
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
165
+ end
166
+
167
+ pattern = Regexp.new(/[A-Z0-9]{4,20}/)
168
+ if @id !~ pattern
169
+ invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
170
+ end
171
+
172
+ pattern = Regexp.new(/[A-Z0-9]{4,20}/)
173
+ if !@campaign_id.nil? && @campaign_id !~ pattern
174
+ invalid_properties.push("invalid value for \"campaign_id\", must conform to the pattern #{pattern}.")
175
+ end
176
+
177
+ if @created_at.nil?
178
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
179
+ end
180
+
181
+ if @status.nil?
182
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
183
+ end
184
+
185
+ invalid_properties
186
+ end
187
+
188
+ # Check to see if the all the properties in the model are valid
189
+ # @return true if the model is valid
190
+ def valid?
191
+ warn '[DEPRECATED] the `valid?` method is obsolete'
192
+ return false if @id.nil?
193
+ return false if @id !~ Regexp.new(/[A-Z0-9]{4,20}/)
194
+ return false if !@campaign_id.nil? && @campaign_id !~ Regexp.new(/[A-Z0-9]{4,20}/)
195
+ return false if @created_at.nil?
196
+ return false if @status.nil?
197
+ status_validator = EnumAttributeValidator.new('String', ["CANCELED", "CART", "EXECUTED", "FAILED", "PENDING APPROVAL", "PENDING INTERNAL PAYMENT APPROVAL"])
198
+ return false unless status_validator.valid?(@status)
199
+ true
200
+ end
201
+
202
+ # Custom attribute writer method with validation
203
+ # @param [Object] id Value to be assigned
204
+ def id=(id)
205
+ if id.nil?
206
+ fail ArgumentError, 'id cannot be nil'
207
+ end
208
+
209
+ pattern = Regexp.new(/[A-Z0-9]{4,20}/)
210
+ if id !~ pattern
211
+ fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
212
+ end
213
+
214
+ @id = id
215
+ end
216
+
217
+ # Custom attribute writer method with validation
218
+ # @param [Object] campaign_id Value to be assigned
219
+ def campaign_id=(campaign_id)
220
+ pattern = Regexp.new(/[A-Z0-9]{4,20}/)
221
+ if !campaign_id.nil? && campaign_id !~ pattern
222
+ fail ArgumentError, "invalid value for \"campaign_id\", must conform to the pattern #{pattern}."
223
+ end
224
+
225
+ @campaign_id = campaign_id
226
+ end
227
+
228
+ # Custom attribute writer method checking allowed values (enum).
229
+ # @param [Object] status Object to be assigned
230
+ def status=(status)
231
+ validator = EnumAttributeValidator.new('String', ["CANCELED", "CART", "EXECUTED", "FAILED", "PENDING APPROVAL", "PENDING INTERNAL PAYMENT APPROVAL"])
232
+ unless validator.valid?(status)
233
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
234
+ end
235
+ @status = status
236
+ end
237
+
238
+ # Checks equality by comparing each attribute.
239
+ # @param [Object] Object to be compared
240
+ def ==(o)
241
+ return true if self.equal?(o)
242
+ self.class == o.class &&
243
+ id == o.id &&
244
+ external_id == o.external_id &&
245
+ campaign_id == o.campaign_id &&
246
+ created_at == o.created_at &&
247
+ status == o.status &&
248
+ payment == o.payment &&
249
+ invoice_id == o.invoice_id &&
250
+ reward == o.reward
251
+ end
252
+
253
+ # @see the `==` method
254
+ # @param [Object] Object to be compared
255
+ def eql?(o)
256
+ self == o
257
+ end
258
+
259
+ # Calculates hash code according to all attributes.
260
+ # @return [Integer] Hash code
261
+ def hash
262
+ [id, external_id, campaign_id, created_at, status, payment, invoice_id, reward].hash
263
+ end
264
+
265
+ # Builds the object from hash
266
+ # @param [Hash] attributes Model attributes in the form of hash
267
+ # @return [Object] Returns the model itself
268
+ def self.build_from_hash(attributes)
269
+ return nil unless attributes.is_a?(Hash)
270
+ attributes = attributes.transform_keys(&:to_sym)
271
+ transformed_hash = {}
272
+ openapi_types.each_pair do |key, type|
273
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
274
+ transformed_hash["#{key}"] = nil
275
+ elsif type =~ /\AArray<(.*)>/i
276
+ # check to ensure the input is an array given that the attribute
277
+ # is documented as an array but the input is not
278
+ if attributes[attribute_map[key]].is_a?(Array)
279
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
280
+ end
281
+ elsif !attributes[attribute_map[key]].nil?
282
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
283
+ end
284
+ end
285
+ new(transformed_hash)
286
+ end
287
+
288
+ # Deserializes the data based on type
289
+ # @param string type Data type
290
+ # @param string value Value to be deserialized
291
+ # @return [Object] Deserialized data
292
+ def self._deserialize(type, value)
293
+ case type.to_sym
294
+ when :Time
295
+ Time.parse(value)
296
+ when :Date
297
+ Date.parse(value)
298
+ when :String
299
+ value.to_s
300
+ when :Integer
301
+ value.to_i
302
+ when :Float
303
+ value.to_f
304
+ when :Boolean
305
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
306
+ true
307
+ else
308
+ false
309
+ end
310
+ when :Object
311
+ # generic object (usually a Hash), return directly
312
+ value
313
+ when /\AArray<(?<inner_type>.+)>\z/
314
+ inner_type = Regexp.last_match[:inner_type]
315
+ value.map { |v| _deserialize(inner_type, v) }
316
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
317
+ k_type = Regexp.last_match[:k_type]
318
+ v_type = Regexp.last_match[:v_type]
319
+ {}.tap do |hash|
320
+ value.each do |k, v|
321
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
322
+ end
323
+ end
324
+ else # model
325
+ # models (e.g. Pet) or oneOf
326
+ klass = Tremendous.const_get(type)
327
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
328
+ end
329
+ end
330
+
331
+ # Returns the string representation of the object
332
+ # @return [String] String presentation of the object
333
+ def to_s
334
+ to_hash.to_s
335
+ end
336
+
337
+ # to_body is an alias to to_hash (backward compatibility)
338
+ # @return [Hash] Returns the object in the form of hash
339
+ def to_body
340
+ to_hash
341
+ end
342
+
343
+ # Returns the object in the form of hash
344
+ # @return [Hash] Returns the object in the form of hash
345
+ def to_hash
346
+ hash = {}
347
+ self.class.attribute_map.each_pair do |attr, param|
348
+ value = self.send(attr)
349
+ if value.nil?
350
+ is_nullable = self.class.openapi_nullable.include?(attr)
351
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
352
+ end
353
+
354
+ hash[param] = _to_hash(value)
355
+ end
356
+ hash
357
+ end
358
+
359
+ # Outputs non-array value in the form of hash
360
+ # For object, use to_hash. Otherwise, just return the value
361
+ # @param [Object] value Any valid value
362
+ # @return [Hash] Returns the value in the form of hash
363
+ def _to_hash(value)
364
+ if value.is_a?(Array)
365
+ value.compact.map { |v| _to_hash(v) }
366
+ elsif value.is_a?(Hash)
367
+ {}.tap do |hash|
368
+ value.each { |k, v| hash[k] = _to_hash(v) }
369
+ end
370
+ elsif value.respond_to? :to_hash
371
+ value.to_hash
372
+ else
373
+ value
374
+ end
375
+ end
376
+
377
+ end
378
+
379
+ end