pnap_billing_api 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +187 -0
  4. data/Rakefile +10 -0
  5. data/VERSION +1 -0
  6. data/docs/ApplicableDiscounts.md +20 -0
  7. data/docs/BandwidthDetails.md +24 -0
  8. data/docs/BandwidthRecord.md +56 -0
  9. data/docs/BillingConfigurationsApi.md +74 -0
  10. data/docs/ConfigurationDetails.md +18 -0
  11. data/docs/DiscountDetails.md +22 -0
  12. data/docs/Error.md +20 -0
  13. data/docs/LocationAvailabilityDetail.md +26 -0
  14. data/docs/LocationEnum.md +15 -0
  15. data/docs/OperatingSystemDetails.md +20 -0
  16. data/docs/OperatingSystemRecord.md +56 -0
  17. data/docs/PriceUnitEnum.md +15 -0
  18. data/docs/PricingPlan.md +36 -0
  19. data/docs/Product.md +22 -0
  20. data/docs/ProductAvailability.md +22 -0
  21. data/docs/ProductCategoryEnum.md +15 -0
  22. data/docs/ProductsApi.md +167 -0
  23. data/docs/ProductsGet200ResponseInner.md +82 -0
  24. data/docs/PublicSubnetDetails.md +22 -0
  25. data/docs/PublicSubnetRecord.md +56 -0
  26. data/docs/RatedUsageApi.md +155 -0
  27. data/docs/RatedUsageGet200ResponseInner.md +88 -0
  28. data/docs/RatedUsageRecord.md +54 -0
  29. data/docs/Reservation.md +48 -0
  30. data/docs/ReservationAutoRenewDisableRequest.md +18 -0
  31. data/docs/ReservationInvoicingModelEnum.md +15 -0
  32. data/docs/ReservationModelEnum.md +15 -0
  33. data/docs/ReservationRequest.md +18 -0
  34. data/docs/ReservationsApi.md +439 -0
  35. data/docs/ServerDetails.md +20 -0
  36. data/docs/ServerProduct.md +24 -0
  37. data/docs/ServerProductMetadata.md +30 -0
  38. data/docs/ServerRecord.md +56 -0
  39. data/docs/StorageDetails.md +28 -0
  40. data/docs/StorageRecord.md +56 -0
  41. data/docs/ThresholdConfigurationDetails.md +18 -0
  42. data/lib/pnap_billing_api/api/billing_configurations_api.rb +79 -0
  43. data/lib/pnap_billing_api/api/products_api.rb +174 -0
  44. data/lib/pnap_billing_api/api/rated_usage_api.rb +156 -0
  45. data/lib/pnap_billing_api/api/reservations_api.rb +412 -0
  46. data/lib/pnap_billing_api/api_client.rb +397 -0
  47. data/lib/pnap_billing_api/api_error.rb +58 -0
  48. data/lib/pnap_billing_api/configuration.rb +298 -0
  49. data/lib/pnap_billing_api/models/applicable_discounts.rb +227 -0
  50. data/lib/pnap_billing_api/models/bandwidth_details.rb +294 -0
  51. data/lib/pnap_billing_api/models/bandwidth_record.rb +548 -0
  52. data/lib/pnap_billing_api/models/configuration_details.rb +215 -0
  53. data/lib/pnap_billing_api/models/discount_details.rb +291 -0
  54. data/lib/pnap_billing_api/models/error.rb +234 -0
  55. data/lib/pnap_billing_api/models/location_availability_detail.rb +314 -0
  56. data/lib/pnap_billing_api/models/location_enum.rb +45 -0
  57. data/lib/pnap_billing_api/models/operating_system_details.rb +240 -0
  58. data/lib/pnap_billing_api/models/operating_system_record.rb +548 -0
  59. data/lib/pnap_billing_api/models/price_unit_enum.rb +44 -0
  60. data/lib/pnap_billing_api/models/pricing_plan.rb +397 -0
  61. data/lib/pnap_billing_api/models/product.rb +252 -0
  62. data/lib/pnap_billing_api/models/product_availability.rb +258 -0
  63. data/lib/pnap_billing_api/models/product_category_enum.rb +43 -0
  64. data/lib/pnap_billing_api/models/products_get200_response_inner.rb +61 -0
  65. data/lib/pnap_billing_api/models/public_subnet_details.rb +250 -0
  66. data/lib/pnap_billing_api/models/public_subnet_record.rb +548 -0
  67. data/lib/pnap_billing_api/models/rated_usage_get200_response_inner.rb +64 -0
  68. data/lib/pnap_billing_api/models/rated_usage_record.rb +526 -0
  69. data/lib/pnap_billing_api/models/reservation.rb +466 -0
  70. data/lib/pnap_billing_api/models/reservation_auto_renew_disable_request.rb +215 -0
  71. data/lib/pnap_billing_api/models/reservation_invoicing_model_enum.rb +40 -0
  72. data/lib/pnap_billing_api/models/reservation_model_enum.rb +43 -0
  73. data/lib/pnap_billing_api/models/reservation_request.rb +223 -0
  74. data/lib/pnap_billing_api/models/server_details.rb +240 -0
  75. data/lib/pnap_billing_api/models/server_product.rb +274 -0
  76. data/lib/pnap_billing_api/models/server_product_metadata.rb +325 -0
  77. data/lib/pnap_billing_api/models/server_record.rb +548 -0
  78. data/lib/pnap_billing_api/models/storage_details.rb +308 -0
  79. data/lib/pnap_billing_api/models/storage_record.rb +548 -0
  80. data/lib/pnap_billing_api/models/threshold_configuration_details.rb +223 -0
  81. data/lib/pnap_billing_api/version.rb +19 -0
  82. data/lib/pnap_billing_api.rb +75 -0
  83. data/pnap_billing_api.gemspec +39 -0
  84. data/spec/api/billing_configurations_api_spec.rb +46 -0
  85. data/spec/api/products_api_spec.rb +67 -0
  86. data/spec/api/rated_usage_api_spec.rb +61 -0
  87. data/spec/api/reservations_api_spec.rb +109 -0
  88. data/spec/models/applicable_discounts_spec.rb +42 -0
  89. data/spec/models/bandwidth_details_spec.rb +58 -0
  90. data/spec/models/bandwidth_record_spec.rb +154 -0
  91. data/spec/models/configuration_details_spec.rb +36 -0
  92. data/spec/models/discount_details_spec.rb +52 -0
  93. data/spec/models/error_spec.rb +42 -0
  94. data/spec/models/location_availability_detail_spec.rb +64 -0
  95. data/spec/models/location_enum_spec.rb +30 -0
  96. data/spec/models/operating_system_details_spec.rb +42 -0
  97. data/spec/models/operating_system_record_spec.rb +154 -0
  98. data/spec/models/price_unit_enum_spec.rb +30 -0
  99. data/spec/models/pricing_plan_spec.rb +102 -0
  100. data/spec/models/product_availability_spec.rb +48 -0
  101. data/spec/models/product_category_enum_spec.rb +30 -0
  102. data/spec/models/product_spec.rb +48 -0
  103. data/spec/models/products_get200_response_inner_spec.rb +44 -0
  104. data/spec/models/public_subnet_details_spec.rb +48 -0
  105. data/spec/models/public_subnet_record_spec.rb +154 -0
  106. data/spec/models/rated_usage_get200_response_inner_spec.rb +44 -0
  107. data/spec/models/rated_usage_record_spec.rb +148 -0
  108. data/spec/models/reservation_auto_renew_disable_request_spec.rb +36 -0
  109. data/spec/models/reservation_invoicing_model_enum_spec.rb +30 -0
  110. data/spec/models/reservation_model_enum_spec.rb +30 -0
  111. data/spec/models/reservation_request_spec.rb +36 -0
  112. data/spec/models/reservation_spec.rb +130 -0
  113. data/spec/models/server_details_spec.rb +42 -0
  114. data/spec/models/server_product_metadata_spec.rb +72 -0
  115. data/spec/models/server_product_spec.rb +54 -0
  116. data/spec/models/server_record_spec.rb +154 -0
  117. data/spec/models/storage_details_spec.rb +66 -0
  118. data/spec/models/storage_record_spec.rb +154 -0
  119. data/spec/models/threshold_configuration_details_spec.rb +36 -0
  120. data/spec/spec_helper.rb +111 -0
  121. metadata +240 -0
@@ -0,0 +1,526 @@
1
+ =begin
2
+ #Billing API
3
+
4
+ #Automate your infrastructure billing with the Bare Metal Cloud Billing API. Reserve your server instances to ensure guaranteed resource availability for 12, 24, and 36 months. Retrieve your server’s rated usage for a given period and enable or disable auto-renewals.<br> <br> <span class='pnap-api-knowledge-base-link'> Knowledge base articles to help you can be found <a href='https://phoenixnap.com/kb/phoenixnap-bare-metal-cloud-billing-models' target='_blank'>here</a> </span><br> <br> <b>All URLs are relative to (https://api.phoenixnap.com/billing/v1/)</b>
5
+
6
+ The version of the OpenAPI document: 0.1
7
+ Contact: support@phoenixnap.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.2.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module BillingApi
17
+ # Rated usage record.
18
+ class RatedUsageRecord
19
+ # The unique identifier of the rated usage record.
20
+ attr_accessor :id
21
+
22
+ # The category of the product associated with this usage record.
23
+ attr_accessor :product_category
24
+
25
+ # The code identifying the product associated to this usage record.
26
+ attr_accessor :product_code
27
+
28
+ attr_accessor :location
29
+
30
+ # Year and month of the usage record.
31
+ attr_accessor :year_month
32
+
33
+ # The point in time (in UTC) when usage has started.
34
+ attr_accessor :start_date_time
35
+
36
+ # The point in time (in UTC) until usage has been rated.
37
+ attr_accessor :end_date_time
38
+
39
+ # The rated usage in cents.
40
+ attr_accessor :cost
41
+
42
+ # The cost in cents before discount.
43
+ attr_accessor :cost_before_discount
44
+
45
+ # The rated usage cost description.
46
+ attr_accessor :cost_description
47
+
48
+ # The price model applied to this usage record.
49
+ attr_accessor :price_model
50
+
51
+ # The unit price.
52
+ attr_accessor :unit_price
53
+
54
+ # User friendly description of the unit price.
55
+ attr_accessor :unit_price_description
56
+
57
+ # The number of units being charged.
58
+ attr_accessor :quantity
59
+
60
+ # A flag indicating whether the rated usage record is still active.
61
+ attr_accessor :active
62
+
63
+ # The usage session ID is used to correlate rated usage records across periods of time. For example, a server used for over a month will generate multiple rated usage records. The entire usage session cost can be computed by aggregating the records having the same usage session ID. It is usual to have one rated usage record per month or invoice.
64
+ attr_accessor :usage_session_id
65
+
66
+ # Holds usage record id
67
+ attr_accessor :correlation_id
68
+
69
+ # Reservation id associated with this rated usage record.
70
+ attr_accessor :reservation_id
71
+
72
+ attr_accessor :discount_details
73
+
74
+ class EnumAttributeValidator
75
+ attr_reader :datatype
76
+ attr_reader :allowable_values
77
+
78
+ def initialize(datatype, allowable_values)
79
+ @allowable_values = allowable_values.map do |value|
80
+ case datatype.to_s
81
+ when /Integer/i
82
+ value.to_i
83
+ when /Float/i
84
+ value.to_f
85
+ else
86
+ value
87
+ end
88
+ end
89
+ end
90
+
91
+ def valid?(value)
92
+ !value || allowable_values.include?(value)
93
+ end
94
+ end
95
+
96
+ # Attribute mapping from ruby-style variable name to JSON key.
97
+ def self.attribute_map
98
+ {
99
+ :'id' => :'id',
100
+ :'product_category' => :'productCategory',
101
+ :'product_code' => :'productCode',
102
+ :'location' => :'location',
103
+ :'year_month' => :'yearMonth',
104
+ :'start_date_time' => :'startDateTime',
105
+ :'end_date_time' => :'endDateTime',
106
+ :'cost' => :'cost',
107
+ :'cost_before_discount' => :'costBeforeDiscount',
108
+ :'cost_description' => :'costDescription',
109
+ :'price_model' => :'priceModel',
110
+ :'unit_price' => :'unitPrice',
111
+ :'unit_price_description' => :'unitPriceDescription',
112
+ :'quantity' => :'quantity',
113
+ :'active' => :'active',
114
+ :'usage_session_id' => :'usageSessionId',
115
+ :'correlation_id' => :'correlationId',
116
+ :'reservation_id' => :'reservationId',
117
+ :'discount_details' => :'discountDetails'
118
+ }
119
+ end
120
+
121
+ # Returns all the JSON keys this model knows about
122
+ def self.acceptable_attributes
123
+ attribute_map.values
124
+ end
125
+
126
+ # Attribute type mapping.
127
+ def self.openapi_types
128
+ {
129
+ :'id' => :'String',
130
+ :'product_category' => :'String',
131
+ :'product_code' => :'String',
132
+ :'location' => :'LocationEnum',
133
+ :'year_month' => :'String',
134
+ :'start_date_time' => :'Time',
135
+ :'end_date_time' => :'Time',
136
+ :'cost' => :'Integer',
137
+ :'cost_before_discount' => :'Integer',
138
+ :'cost_description' => :'String',
139
+ :'price_model' => :'String',
140
+ :'unit_price' => :'Float',
141
+ :'unit_price_description' => :'String',
142
+ :'quantity' => :'Float',
143
+ :'active' => :'Boolean',
144
+ :'usage_session_id' => :'String',
145
+ :'correlation_id' => :'String',
146
+ :'reservation_id' => :'String',
147
+ :'discount_details' => :'DiscountDetails'
148
+ }
149
+ end
150
+
151
+ # List of attributes with nullable: true
152
+ def self.openapi_nullable
153
+ Set.new([
154
+ ])
155
+ end
156
+
157
+ # Initializes the object
158
+ # @param [Hash] attributes Model attributes in the form of hash
159
+ def initialize(attributes = {})
160
+ if (!attributes.is_a?(Hash))
161
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BillingApi::RatedUsageRecord` initialize method"
162
+ end
163
+
164
+ # check to see if the attribute exists and convert string to symbol for hash key
165
+ attributes = attributes.each_with_object({}) { |(k, v), h|
166
+ if (!self.class.attribute_map.key?(k.to_sym))
167
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BillingApi::RatedUsageRecord`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
168
+ end
169
+ h[k.to_sym] = v
170
+ }
171
+
172
+ if attributes.key?(:'id')
173
+ self.id = attributes[:'id']
174
+ else
175
+ self.id = nil
176
+ end
177
+
178
+ if attributes.key?(:'product_category')
179
+ self.product_category = attributes[:'product_category']
180
+ else
181
+ self.product_category = nil
182
+ end
183
+
184
+ if attributes.key?(:'product_code')
185
+ self.product_code = attributes[:'product_code']
186
+ else
187
+ self.product_code = nil
188
+ end
189
+
190
+ if attributes.key?(:'location')
191
+ self.location = attributes[:'location']
192
+ else
193
+ self.location = nil
194
+ end
195
+
196
+ if attributes.key?(:'year_month')
197
+ self.year_month = attributes[:'year_month']
198
+ end
199
+
200
+ if attributes.key?(:'start_date_time')
201
+ self.start_date_time = attributes[:'start_date_time']
202
+ else
203
+ self.start_date_time = nil
204
+ end
205
+
206
+ if attributes.key?(:'end_date_time')
207
+ self.end_date_time = attributes[:'end_date_time']
208
+ else
209
+ self.end_date_time = nil
210
+ end
211
+
212
+ if attributes.key?(:'cost')
213
+ self.cost = attributes[:'cost']
214
+ else
215
+ self.cost = nil
216
+ end
217
+
218
+ if attributes.key?(:'cost_before_discount')
219
+ self.cost_before_discount = attributes[:'cost_before_discount']
220
+ end
221
+
222
+ if attributes.key?(:'cost_description')
223
+ self.cost_description = attributes[:'cost_description']
224
+ end
225
+
226
+ if attributes.key?(:'price_model')
227
+ self.price_model = attributes[:'price_model']
228
+ else
229
+ self.price_model = nil
230
+ end
231
+
232
+ if attributes.key?(:'unit_price')
233
+ self.unit_price = attributes[:'unit_price']
234
+ else
235
+ self.unit_price = nil
236
+ end
237
+
238
+ if attributes.key?(:'unit_price_description')
239
+ self.unit_price_description = attributes[:'unit_price_description']
240
+ else
241
+ self.unit_price_description = nil
242
+ end
243
+
244
+ if attributes.key?(:'quantity')
245
+ self.quantity = attributes[:'quantity']
246
+ else
247
+ self.quantity = nil
248
+ end
249
+
250
+ if attributes.key?(:'active')
251
+ self.active = attributes[:'active']
252
+ else
253
+ self.active = nil
254
+ end
255
+
256
+ if attributes.key?(:'usage_session_id')
257
+ self.usage_session_id = attributes[:'usage_session_id']
258
+ else
259
+ self.usage_session_id = nil
260
+ end
261
+
262
+ if attributes.key?(:'correlation_id')
263
+ self.correlation_id = attributes[:'correlation_id']
264
+ else
265
+ self.correlation_id = nil
266
+ end
267
+
268
+ if attributes.key?(:'reservation_id')
269
+ self.reservation_id = attributes[:'reservation_id']
270
+ end
271
+
272
+ if attributes.key?(:'discount_details')
273
+ self.discount_details = attributes[:'discount_details']
274
+ end
275
+ end
276
+
277
+ # Show invalid properties with the reasons. Usually used together with valid?
278
+ # @return Array for valid properties with the reasons
279
+ def list_invalid_properties
280
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
281
+ invalid_properties = Array.new
282
+ if @id.nil?
283
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
284
+ end
285
+
286
+ if @product_category.nil?
287
+ invalid_properties.push('invalid value for "product_category", product_category cannot be nil.')
288
+ end
289
+
290
+ if @product_code.nil?
291
+ invalid_properties.push('invalid value for "product_code", product_code cannot be nil.')
292
+ end
293
+
294
+ if @location.nil?
295
+ invalid_properties.push('invalid value for "location", location cannot be nil.')
296
+ end
297
+
298
+ if @start_date_time.nil?
299
+ invalid_properties.push('invalid value for "start_date_time", start_date_time cannot be nil.')
300
+ end
301
+
302
+ if @end_date_time.nil?
303
+ invalid_properties.push('invalid value for "end_date_time", end_date_time cannot be nil.')
304
+ end
305
+
306
+ if @cost.nil?
307
+ invalid_properties.push('invalid value for "cost", cost cannot be nil.')
308
+ end
309
+
310
+ if @price_model.nil?
311
+ invalid_properties.push('invalid value for "price_model", price_model cannot be nil.')
312
+ end
313
+
314
+ if @unit_price.nil?
315
+ invalid_properties.push('invalid value for "unit_price", unit_price cannot be nil.')
316
+ end
317
+
318
+ if @unit_price_description.nil?
319
+ invalid_properties.push('invalid value for "unit_price_description", unit_price_description cannot be nil.')
320
+ end
321
+
322
+ if @quantity.nil?
323
+ invalid_properties.push('invalid value for "quantity", quantity cannot be nil.')
324
+ end
325
+
326
+ if @active.nil?
327
+ invalid_properties.push('invalid value for "active", active cannot be nil.')
328
+ end
329
+
330
+ if @usage_session_id.nil?
331
+ invalid_properties.push('invalid value for "usage_session_id", usage_session_id cannot be nil.')
332
+ end
333
+
334
+ if @correlation_id.nil?
335
+ invalid_properties.push('invalid value for "correlation_id", correlation_id cannot be nil.')
336
+ end
337
+
338
+ invalid_properties
339
+ end
340
+
341
+ # Check to see if the all the properties in the model are valid
342
+ # @return true if the model is valid
343
+ def valid?
344
+ warn '[DEPRECATED] the `valid?` method is obsolete'
345
+ return false if @id.nil?
346
+ return false if @product_category.nil?
347
+ product_category_validator = EnumAttributeValidator.new('String', ["bmc-server", "bandwidth", "operating-system", "public-ip", "storage"])
348
+ return false unless product_category_validator.valid?(@product_category)
349
+ return false if @product_code.nil?
350
+ return false if @location.nil?
351
+ return false if @start_date_time.nil?
352
+ return false if @end_date_time.nil?
353
+ return false if @cost.nil?
354
+ return false if @price_model.nil?
355
+ return false if @unit_price.nil?
356
+ return false if @unit_price_description.nil?
357
+ return false if @quantity.nil?
358
+ return false if @active.nil?
359
+ return false if @usage_session_id.nil?
360
+ return false if @correlation_id.nil?
361
+ true
362
+ end
363
+
364
+ # Custom attribute writer method checking allowed values (enum).
365
+ # @param [Object] product_category Object to be assigned
366
+ def product_category=(product_category)
367
+ validator = EnumAttributeValidator.new('String', ["bmc-server", "bandwidth", "operating-system", "public-ip", "storage"])
368
+ unless validator.valid?(product_category)
369
+ fail ArgumentError, "invalid value for \"product_category\", must be one of #{validator.allowable_values}."
370
+ end
371
+ @product_category = product_category
372
+ end
373
+
374
+ # Checks equality by comparing each attribute.
375
+ # @param [Object] Object to be compared
376
+ def ==(o)
377
+ return true if self.equal?(o)
378
+ self.class == o.class &&
379
+ id == o.id &&
380
+ product_category == o.product_category &&
381
+ product_code == o.product_code &&
382
+ location == o.location &&
383
+ year_month == o.year_month &&
384
+ start_date_time == o.start_date_time &&
385
+ end_date_time == o.end_date_time &&
386
+ cost == o.cost &&
387
+ cost_before_discount == o.cost_before_discount &&
388
+ cost_description == o.cost_description &&
389
+ price_model == o.price_model &&
390
+ unit_price == o.unit_price &&
391
+ unit_price_description == o.unit_price_description &&
392
+ quantity == o.quantity &&
393
+ active == o.active &&
394
+ usage_session_id == o.usage_session_id &&
395
+ correlation_id == o.correlation_id &&
396
+ reservation_id == o.reservation_id &&
397
+ discount_details == o.discount_details
398
+ end
399
+
400
+ # @see the `==` method
401
+ # @param [Object] Object to be compared
402
+ def eql?(o)
403
+ self == o
404
+ end
405
+
406
+ # Calculates hash code according to all attributes.
407
+ # @return [Integer] Hash code
408
+ def hash
409
+ [id, product_category, product_code, location, year_month, start_date_time, end_date_time, cost, cost_before_discount, cost_description, price_model, unit_price, unit_price_description, quantity, active, usage_session_id, correlation_id, reservation_id, discount_details].hash
410
+ end
411
+
412
+ # Builds the object from hash
413
+ # @param [Hash] attributes Model attributes in the form of hash
414
+ # @return [Object] Returns the model itself
415
+ def self.build_from_hash(attributes)
416
+ return nil unless attributes.is_a?(Hash)
417
+ attributes = attributes.transform_keys(&:to_sym)
418
+ transformed_hash = {}
419
+ openapi_types.each_pair do |key, type|
420
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
421
+ transformed_hash["#{key}"] = nil
422
+ elsif type =~ /\AArray<(.*)>/i
423
+ # check to ensure the input is an array given that the attribute
424
+ # is documented as an array but the input is not
425
+ if attributes[attribute_map[key]].is_a?(Array)
426
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
427
+ end
428
+ elsif !attributes[attribute_map[key]].nil?
429
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
430
+ end
431
+ end
432
+ new(transformed_hash)
433
+ end
434
+
435
+ # Deserializes the data based on type
436
+ # @param string type Data type
437
+ # @param string value Value to be deserialized
438
+ # @return [Object] Deserialized data
439
+ def self._deserialize(type, value)
440
+ case type.to_sym
441
+ when :Time
442
+ Time.parse(value)
443
+ when :Date
444
+ Date.parse(value)
445
+ when :String
446
+ value.to_s
447
+ when :Integer
448
+ value.to_i
449
+ when :Float
450
+ value.to_f
451
+ when :Boolean
452
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
453
+ true
454
+ else
455
+ false
456
+ end
457
+ when :Object
458
+ # generic object (usually a Hash), return directly
459
+ value
460
+ when /\AArray<(?<inner_type>.+)>\z/
461
+ inner_type = Regexp.last_match[:inner_type]
462
+ value.map { |v| _deserialize(inner_type, v) }
463
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
464
+ k_type = Regexp.last_match[:k_type]
465
+ v_type = Regexp.last_match[:v_type]
466
+ {}.tap do |hash|
467
+ value.each do |k, v|
468
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
469
+ end
470
+ end
471
+ else # model
472
+ # models (e.g. Pet) or oneOf
473
+ klass = BillingApi.const_get(type)
474
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
475
+ end
476
+ end
477
+
478
+ # Returns the string representation of the object
479
+ # @return [String] String presentation of the object
480
+ def to_s
481
+ to_hash.to_s
482
+ end
483
+
484
+ # to_body is an alias to to_hash (backward compatibility)
485
+ # @return [Hash] Returns the object in the form of hash
486
+ def to_body
487
+ to_hash
488
+ end
489
+
490
+ # Returns the object in the form of hash
491
+ # @return [Hash] Returns the object in the form of hash
492
+ def to_hash
493
+ hash = {}
494
+ self.class.attribute_map.each_pair do |attr, param|
495
+ value = self.send(attr)
496
+ if value.nil?
497
+ is_nullable = self.class.openapi_nullable.include?(attr)
498
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
499
+ end
500
+
501
+ hash[param] = _to_hash(value)
502
+ end
503
+ hash
504
+ end
505
+
506
+ # Outputs non-array value in the form of hash
507
+ # For object, use to_hash. Otherwise, just return the value
508
+ # @param [Object] value Any valid value
509
+ # @return [Hash] Returns the value in the form of hash
510
+ def _to_hash(value)
511
+ if value.is_a?(Array)
512
+ value.compact.map { |v| _to_hash(v) }
513
+ elsif value.is_a?(Hash)
514
+ {}.tap do |hash|
515
+ value.each { |k, v| hash[k] = _to_hash(v) }
516
+ end
517
+ elsif value.respond_to? :to_hash
518
+ value.to_hash
519
+ else
520
+ value
521
+ end
522
+ end
523
+
524
+ end
525
+
526
+ end