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,548 @@
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
+ class ServerRecord
18
+ # The unique identifier of the rated usage record.
19
+ attr_accessor :id
20
+
21
+ # The category of the product associated with this usage record.
22
+ attr_accessor :product_category
23
+
24
+ # The code identifying the product associated to this usage record.
25
+ attr_accessor :product_code
26
+
27
+ attr_accessor :location
28
+
29
+ # Year and month of the usage record.
30
+ attr_accessor :year_month
31
+
32
+ # The point in time (in UTC) when usage has started.
33
+ attr_accessor :start_date_time
34
+
35
+ # The point in time (in UTC) until usage has been rated.
36
+ attr_accessor :end_date_time
37
+
38
+ # The rated usage in cents.
39
+ attr_accessor :cost
40
+
41
+ # The cost in cents before discount.
42
+ attr_accessor :cost_before_discount
43
+
44
+ # The rated usage cost description.
45
+ attr_accessor :cost_description
46
+
47
+ # The price model applied to this usage record.
48
+ attr_accessor :price_model
49
+
50
+ # The unit price.
51
+ attr_accessor :unit_price
52
+
53
+ # User friendly description of the unit price.
54
+ attr_accessor :unit_price_description
55
+
56
+ # The number of units being charged.
57
+ attr_accessor :quantity
58
+
59
+ # A flag indicating whether the rated usage record is still active.
60
+ attr_accessor :active
61
+
62
+ # 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.
63
+ attr_accessor :usage_session_id
64
+
65
+ # Holds usage record id
66
+ attr_accessor :correlation_id
67
+
68
+ # Reservation id associated with this rated usage record.
69
+ attr_accessor :reservation_id
70
+
71
+ attr_accessor :discount_details
72
+
73
+ attr_accessor :metadata
74
+
75
+ class EnumAttributeValidator
76
+ attr_reader :datatype
77
+ attr_reader :allowable_values
78
+
79
+ def initialize(datatype, allowable_values)
80
+ @allowable_values = allowable_values.map do |value|
81
+ case datatype.to_s
82
+ when /Integer/i
83
+ value.to_i
84
+ when /Float/i
85
+ value.to_f
86
+ else
87
+ value
88
+ end
89
+ end
90
+ end
91
+
92
+ def valid?(value)
93
+ !value || allowable_values.include?(value)
94
+ end
95
+ end
96
+
97
+ # Attribute mapping from ruby-style variable name to JSON key.
98
+ def self.attribute_map
99
+ {
100
+ :'id' => :'id',
101
+ :'product_category' => :'productCategory',
102
+ :'product_code' => :'productCode',
103
+ :'location' => :'location',
104
+ :'year_month' => :'yearMonth',
105
+ :'start_date_time' => :'startDateTime',
106
+ :'end_date_time' => :'endDateTime',
107
+ :'cost' => :'cost',
108
+ :'cost_before_discount' => :'costBeforeDiscount',
109
+ :'cost_description' => :'costDescription',
110
+ :'price_model' => :'priceModel',
111
+ :'unit_price' => :'unitPrice',
112
+ :'unit_price_description' => :'unitPriceDescription',
113
+ :'quantity' => :'quantity',
114
+ :'active' => :'active',
115
+ :'usage_session_id' => :'usageSessionId',
116
+ :'correlation_id' => :'correlationId',
117
+ :'reservation_id' => :'reservationId',
118
+ :'discount_details' => :'discountDetails',
119
+ :'metadata' => :'metadata'
120
+ }
121
+ end
122
+
123
+ # Returns all the JSON keys this model knows about
124
+ def self.acceptable_attributes
125
+ attribute_map.values
126
+ end
127
+
128
+ # Attribute type mapping.
129
+ def self.openapi_types
130
+ {
131
+ :'id' => :'String',
132
+ :'product_category' => :'String',
133
+ :'product_code' => :'String',
134
+ :'location' => :'LocationEnum',
135
+ :'year_month' => :'String',
136
+ :'start_date_time' => :'Time',
137
+ :'end_date_time' => :'Time',
138
+ :'cost' => :'Integer',
139
+ :'cost_before_discount' => :'Integer',
140
+ :'cost_description' => :'String',
141
+ :'price_model' => :'String',
142
+ :'unit_price' => :'Float',
143
+ :'unit_price_description' => :'String',
144
+ :'quantity' => :'Float',
145
+ :'active' => :'Boolean',
146
+ :'usage_session_id' => :'String',
147
+ :'correlation_id' => :'String',
148
+ :'reservation_id' => :'String',
149
+ :'discount_details' => :'DiscountDetails',
150
+ :'metadata' => :'ServerDetails'
151
+ }
152
+ end
153
+
154
+ # List of attributes with nullable: true
155
+ def self.openapi_nullable
156
+ Set.new([
157
+ ])
158
+ end
159
+
160
+ # List of class defined in allOf (OpenAPI v3)
161
+ def self.openapi_all_of
162
+ [
163
+ :'RatedUsageRecord'
164
+ ]
165
+ end
166
+
167
+ # Initializes the object
168
+ # @param [Hash] attributes Model attributes in the form of hash
169
+ def initialize(attributes = {})
170
+ if (!attributes.is_a?(Hash))
171
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BillingApi::ServerRecord` initialize method"
172
+ end
173
+
174
+ # check to see if the attribute exists and convert string to symbol for hash key
175
+ attributes = attributes.each_with_object({}) { |(k, v), h|
176
+ if (!self.class.attribute_map.key?(k.to_sym))
177
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BillingApi::ServerRecord`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
178
+ end
179
+ h[k.to_sym] = v
180
+ }
181
+
182
+ if attributes.key?(:'id')
183
+ self.id = attributes[:'id']
184
+ else
185
+ self.id = nil
186
+ end
187
+
188
+ if attributes.key?(:'product_category')
189
+ self.product_category = attributes[:'product_category']
190
+ else
191
+ self.product_category = nil
192
+ end
193
+
194
+ if attributes.key?(:'product_code')
195
+ self.product_code = attributes[:'product_code']
196
+ else
197
+ self.product_code = nil
198
+ end
199
+
200
+ if attributes.key?(:'location')
201
+ self.location = attributes[:'location']
202
+ else
203
+ self.location = nil
204
+ end
205
+
206
+ if attributes.key?(:'year_month')
207
+ self.year_month = attributes[:'year_month']
208
+ end
209
+
210
+ if attributes.key?(:'start_date_time')
211
+ self.start_date_time = attributes[:'start_date_time']
212
+ else
213
+ self.start_date_time = nil
214
+ end
215
+
216
+ if attributes.key?(:'end_date_time')
217
+ self.end_date_time = attributes[:'end_date_time']
218
+ else
219
+ self.end_date_time = nil
220
+ end
221
+
222
+ if attributes.key?(:'cost')
223
+ self.cost = attributes[:'cost']
224
+ else
225
+ self.cost = nil
226
+ end
227
+
228
+ if attributes.key?(:'cost_before_discount')
229
+ self.cost_before_discount = attributes[:'cost_before_discount']
230
+ end
231
+
232
+ if attributes.key?(:'cost_description')
233
+ self.cost_description = attributes[:'cost_description']
234
+ end
235
+
236
+ if attributes.key?(:'price_model')
237
+ self.price_model = attributes[:'price_model']
238
+ else
239
+ self.price_model = nil
240
+ end
241
+
242
+ if attributes.key?(:'unit_price')
243
+ self.unit_price = attributes[:'unit_price']
244
+ else
245
+ self.unit_price = nil
246
+ end
247
+
248
+ if attributes.key?(:'unit_price_description')
249
+ self.unit_price_description = attributes[:'unit_price_description']
250
+ else
251
+ self.unit_price_description = nil
252
+ end
253
+
254
+ if attributes.key?(:'quantity')
255
+ self.quantity = attributes[:'quantity']
256
+ else
257
+ self.quantity = nil
258
+ end
259
+
260
+ if attributes.key?(:'active')
261
+ self.active = attributes[:'active']
262
+ else
263
+ self.active = nil
264
+ end
265
+
266
+ if attributes.key?(:'usage_session_id')
267
+ self.usage_session_id = attributes[:'usage_session_id']
268
+ else
269
+ self.usage_session_id = nil
270
+ end
271
+
272
+ if attributes.key?(:'correlation_id')
273
+ self.correlation_id = attributes[:'correlation_id']
274
+ else
275
+ self.correlation_id = nil
276
+ end
277
+
278
+ if attributes.key?(:'reservation_id')
279
+ self.reservation_id = attributes[:'reservation_id']
280
+ end
281
+
282
+ if attributes.key?(:'discount_details')
283
+ self.discount_details = attributes[:'discount_details']
284
+ end
285
+
286
+ if attributes.key?(:'metadata')
287
+ self.metadata = attributes[:'metadata']
288
+ else
289
+ self.metadata = nil
290
+ end
291
+ end
292
+
293
+ # Show invalid properties with the reasons. Usually used together with valid?
294
+ # @return Array for valid properties with the reasons
295
+ def list_invalid_properties
296
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
297
+ invalid_properties = Array.new
298
+ if @id.nil?
299
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
300
+ end
301
+
302
+ if @product_category.nil?
303
+ invalid_properties.push('invalid value for "product_category", product_category cannot be nil.')
304
+ end
305
+
306
+ if @product_code.nil?
307
+ invalid_properties.push('invalid value for "product_code", product_code cannot be nil.')
308
+ end
309
+
310
+ if @location.nil?
311
+ invalid_properties.push('invalid value for "location", location cannot be nil.')
312
+ end
313
+
314
+ if @start_date_time.nil?
315
+ invalid_properties.push('invalid value for "start_date_time", start_date_time cannot be nil.')
316
+ end
317
+
318
+ if @end_date_time.nil?
319
+ invalid_properties.push('invalid value for "end_date_time", end_date_time cannot be nil.')
320
+ end
321
+
322
+ if @cost.nil?
323
+ invalid_properties.push('invalid value for "cost", cost cannot be nil.')
324
+ end
325
+
326
+ if @price_model.nil?
327
+ invalid_properties.push('invalid value for "price_model", price_model cannot be nil.')
328
+ end
329
+
330
+ if @unit_price.nil?
331
+ invalid_properties.push('invalid value for "unit_price", unit_price cannot be nil.')
332
+ end
333
+
334
+ if @unit_price_description.nil?
335
+ invalid_properties.push('invalid value for "unit_price_description", unit_price_description cannot be nil.')
336
+ end
337
+
338
+ if @quantity.nil?
339
+ invalid_properties.push('invalid value for "quantity", quantity cannot be nil.')
340
+ end
341
+
342
+ if @active.nil?
343
+ invalid_properties.push('invalid value for "active", active cannot be nil.')
344
+ end
345
+
346
+ if @usage_session_id.nil?
347
+ invalid_properties.push('invalid value for "usage_session_id", usage_session_id cannot be nil.')
348
+ end
349
+
350
+ if @correlation_id.nil?
351
+ invalid_properties.push('invalid value for "correlation_id", correlation_id cannot be nil.')
352
+ end
353
+
354
+ if @metadata.nil?
355
+ invalid_properties.push('invalid value for "metadata", metadata cannot be nil.')
356
+ end
357
+
358
+ invalid_properties
359
+ end
360
+
361
+ # Check to see if the all the properties in the model are valid
362
+ # @return true if the model is valid
363
+ def valid?
364
+ warn '[DEPRECATED] the `valid?` method is obsolete'
365
+ return false if @id.nil?
366
+ return false if @product_category.nil?
367
+ product_category_validator = EnumAttributeValidator.new('String', ["bmc-server", "bandwidth", "operating-system", "public-ip", "storage"])
368
+ return false unless product_category_validator.valid?(@product_category)
369
+ return false if @product_code.nil?
370
+ return false if @location.nil?
371
+ return false if @start_date_time.nil?
372
+ return false if @end_date_time.nil?
373
+ return false if @cost.nil?
374
+ return false if @price_model.nil?
375
+ return false if @unit_price.nil?
376
+ return false if @unit_price_description.nil?
377
+ return false if @quantity.nil?
378
+ return false if @active.nil?
379
+ return false if @usage_session_id.nil?
380
+ return false if @correlation_id.nil?
381
+ return false if @metadata.nil?
382
+ true
383
+ end
384
+
385
+ # Custom attribute writer method checking allowed values (enum).
386
+ # @param [Object] product_category Object to be assigned
387
+ def product_category=(product_category)
388
+ validator = EnumAttributeValidator.new('String', ["bmc-server", "bandwidth", "operating-system", "public-ip", "storage"])
389
+ unless validator.valid?(product_category)
390
+ fail ArgumentError, "invalid value for \"product_category\", must be one of #{validator.allowable_values}."
391
+ end
392
+ @product_category = product_category
393
+ end
394
+
395
+ # Checks equality by comparing each attribute.
396
+ # @param [Object] Object to be compared
397
+ def ==(o)
398
+ return true if self.equal?(o)
399
+ self.class == o.class &&
400
+ id == o.id &&
401
+ product_category == o.product_category &&
402
+ product_code == o.product_code &&
403
+ location == o.location &&
404
+ year_month == o.year_month &&
405
+ start_date_time == o.start_date_time &&
406
+ end_date_time == o.end_date_time &&
407
+ cost == o.cost &&
408
+ cost_before_discount == o.cost_before_discount &&
409
+ cost_description == o.cost_description &&
410
+ price_model == o.price_model &&
411
+ unit_price == o.unit_price &&
412
+ unit_price_description == o.unit_price_description &&
413
+ quantity == o.quantity &&
414
+ active == o.active &&
415
+ usage_session_id == o.usage_session_id &&
416
+ correlation_id == o.correlation_id &&
417
+ reservation_id == o.reservation_id &&
418
+ discount_details == o.discount_details &&
419
+ metadata == o.metadata
420
+ end
421
+
422
+ # @see the `==` method
423
+ # @param [Object] Object to be compared
424
+ def eql?(o)
425
+ self == o
426
+ end
427
+
428
+ # Calculates hash code according to all attributes.
429
+ # @return [Integer] Hash code
430
+ def hash
431
+ [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, metadata].hash
432
+ end
433
+
434
+ # Builds the object from hash
435
+ # @param [Hash] attributes Model attributes in the form of hash
436
+ # @return [Object] Returns the model itself
437
+ def self.build_from_hash(attributes)
438
+ return nil unless attributes.is_a?(Hash)
439
+ attributes = attributes.transform_keys(&:to_sym)
440
+ transformed_hash = {}
441
+ openapi_types.each_pair do |key, type|
442
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
443
+ transformed_hash["#{key}"] = nil
444
+ elsif type =~ /\AArray<(.*)>/i
445
+ # check to ensure the input is an array given that the attribute
446
+ # is documented as an array but the input is not
447
+ if attributes[attribute_map[key]].is_a?(Array)
448
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
449
+ end
450
+ elsif !attributes[attribute_map[key]].nil?
451
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
452
+ end
453
+ end
454
+ new(transformed_hash)
455
+ end
456
+
457
+ # Deserializes the data based on type
458
+ # @param string type Data type
459
+ # @param string value Value to be deserialized
460
+ # @return [Object] Deserialized data
461
+ def self._deserialize(type, value)
462
+ case type.to_sym
463
+ when :Time
464
+ Time.parse(value)
465
+ when :Date
466
+ Date.parse(value)
467
+ when :String
468
+ value.to_s
469
+ when :Integer
470
+ value.to_i
471
+ when :Float
472
+ value.to_f
473
+ when :Boolean
474
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
475
+ true
476
+ else
477
+ false
478
+ end
479
+ when :Object
480
+ # generic object (usually a Hash), return directly
481
+ value
482
+ when /\AArray<(?<inner_type>.+)>\z/
483
+ inner_type = Regexp.last_match[:inner_type]
484
+ value.map { |v| _deserialize(inner_type, v) }
485
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
486
+ k_type = Regexp.last_match[:k_type]
487
+ v_type = Regexp.last_match[:v_type]
488
+ {}.tap do |hash|
489
+ value.each do |k, v|
490
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
491
+ end
492
+ end
493
+ else # model
494
+ # models (e.g. Pet) or oneOf
495
+ klass = BillingApi.const_get(type)
496
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
497
+ end
498
+ end
499
+
500
+ # Returns the string representation of the object
501
+ # @return [String] String presentation of the object
502
+ def to_s
503
+ to_hash.to_s
504
+ end
505
+
506
+ # to_body is an alias to to_hash (backward compatibility)
507
+ # @return [Hash] Returns the object in the form of hash
508
+ def to_body
509
+ to_hash
510
+ end
511
+
512
+ # Returns the object in the form of hash
513
+ # @return [Hash] Returns the object in the form of hash
514
+ def to_hash
515
+ hash = {}
516
+ self.class.attribute_map.each_pair do |attr, param|
517
+ value = self.send(attr)
518
+ if value.nil?
519
+ is_nullable = self.class.openapi_nullable.include?(attr)
520
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
521
+ end
522
+
523
+ hash[param] = _to_hash(value)
524
+ end
525
+ hash
526
+ end
527
+
528
+ # Outputs non-array value in the form of hash
529
+ # For object, use to_hash. Otherwise, just return the value
530
+ # @param [Object] value Any valid value
531
+ # @return [Hash] Returns the value in the form of hash
532
+ def _to_hash(value)
533
+ if value.is_a?(Array)
534
+ value.compact.map { |v| _to_hash(v) }
535
+ elsif value.is_a?(Hash)
536
+ {}.tap do |hash|
537
+ value.each { |k, v| hash[k] = _to_hash(v) }
538
+ end
539
+ elsif value.respond_to? :to_hash
540
+ value.to_hash
541
+ else
542
+ value
543
+ end
544
+ end
545
+
546
+ end
547
+
548
+ end