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,466 @@
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
+ # Reservation details
18
+ class Reservation
19
+ # The reservation identifier.
20
+ attr_accessor :id
21
+
22
+ # The code identifying the product. This code has significant across all locations.
23
+ attr_accessor :product_code
24
+
25
+ # The product category.
26
+ attr_accessor :product_category
27
+
28
+ attr_accessor :location
29
+
30
+ attr_accessor :reservation_model
31
+
32
+ attr_accessor :initial_invoice_model
33
+
34
+ # The point in time (in UTC) when the reservation starts.
35
+ attr_accessor :start_date_time
36
+
37
+ # The point in time (in UTC) when the reservation end.
38
+ attr_accessor :end_date_time
39
+
40
+ # The point in time (in UTC) when the reservation was renewed last.
41
+ attr_accessor :last_renewal_date_time
42
+
43
+ # The point in time (in UTC) when the reservation will be renewed if auto renew is set to true.
44
+ attr_accessor :next_renewal_date_time
45
+
46
+ # A flag indicating whether the reservation will auto-renew (default is true).
47
+ attr_accessor :auto_renew
48
+
49
+ # The sku that will be applied to this reservation. It is useful to find out the price by querying the /product endpoint.
50
+ attr_accessor :sku
51
+
52
+ # Reservation price.
53
+ attr_accessor :price
54
+
55
+ attr_accessor :price_unit
56
+
57
+ # The resource ID currently being assigned to Reservation.
58
+ attr_accessor :assigned_resource_id
59
+
60
+ # Next billing date for Reservation.
61
+ attr_accessor :next_billing_date
62
+
63
+ class EnumAttributeValidator
64
+ attr_reader :datatype
65
+ attr_reader :allowable_values
66
+
67
+ def initialize(datatype, allowable_values)
68
+ @allowable_values = allowable_values.map do |value|
69
+ case datatype.to_s
70
+ when /Integer/i
71
+ value.to_i
72
+ when /Float/i
73
+ value.to_f
74
+ else
75
+ value
76
+ end
77
+ end
78
+ end
79
+
80
+ def valid?(value)
81
+ !value || allowable_values.include?(value)
82
+ end
83
+ end
84
+
85
+ # Attribute mapping from ruby-style variable name to JSON key.
86
+ def self.attribute_map
87
+ {
88
+ :'id' => :'id',
89
+ :'product_code' => :'productCode',
90
+ :'product_category' => :'productCategory',
91
+ :'location' => :'location',
92
+ :'reservation_model' => :'reservationModel',
93
+ :'initial_invoice_model' => :'initialInvoiceModel',
94
+ :'start_date_time' => :'startDateTime',
95
+ :'end_date_time' => :'endDateTime',
96
+ :'last_renewal_date_time' => :'lastRenewalDateTime',
97
+ :'next_renewal_date_time' => :'nextRenewalDateTime',
98
+ :'auto_renew' => :'autoRenew',
99
+ :'sku' => :'sku',
100
+ :'price' => :'price',
101
+ :'price_unit' => :'priceUnit',
102
+ :'assigned_resource_id' => :'assignedResourceId',
103
+ :'next_billing_date' => :'nextBillingDate'
104
+ }
105
+ end
106
+
107
+ # Returns all the JSON keys this model knows about
108
+ def self.acceptable_attributes
109
+ attribute_map.values
110
+ end
111
+
112
+ # Attribute type mapping.
113
+ def self.openapi_types
114
+ {
115
+ :'id' => :'String',
116
+ :'product_code' => :'String',
117
+ :'product_category' => :'String',
118
+ :'location' => :'LocationEnum',
119
+ :'reservation_model' => :'ReservationModelEnum',
120
+ :'initial_invoice_model' => :'ReservationInvoicingModelEnum',
121
+ :'start_date_time' => :'Time',
122
+ :'end_date_time' => :'Time',
123
+ :'last_renewal_date_time' => :'Time',
124
+ :'next_renewal_date_time' => :'Time',
125
+ :'auto_renew' => :'Boolean',
126
+ :'sku' => :'String',
127
+ :'price' => :'Float',
128
+ :'price_unit' => :'PriceUnitEnum',
129
+ :'assigned_resource_id' => :'String',
130
+ :'next_billing_date' => :'Date'
131
+ }
132
+ end
133
+
134
+ # List of attributes with nullable: true
135
+ def self.openapi_nullable
136
+ Set.new([
137
+ ])
138
+ end
139
+
140
+ # Initializes the object
141
+ # @param [Hash] attributes Model attributes in the form of hash
142
+ def initialize(attributes = {})
143
+ if (!attributes.is_a?(Hash))
144
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BillingApi::Reservation` initialize method"
145
+ end
146
+
147
+ # check to see if the attribute exists and convert string to symbol for hash key
148
+ attributes = attributes.each_with_object({}) { |(k, v), h|
149
+ if (!self.class.attribute_map.key?(k.to_sym))
150
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BillingApi::Reservation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
151
+ end
152
+ h[k.to_sym] = v
153
+ }
154
+
155
+ if attributes.key?(:'id')
156
+ self.id = attributes[:'id']
157
+ else
158
+ self.id = nil
159
+ end
160
+
161
+ if attributes.key?(:'product_code')
162
+ self.product_code = attributes[:'product_code']
163
+ else
164
+ self.product_code = nil
165
+ end
166
+
167
+ if attributes.key?(:'product_category')
168
+ self.product_category = attributes[:'product_category']
169
+ else
170
+ self.product_category = nil
171
+ end
172
+
173
+ if attributes.key?(:'location')
174
+ self.location = attributes[:'location']
175
+ else
176
+ self.location = nil
177
+ end
178
+
179
+ if attributes.key?(:'reservation_model')
180
+ self.reservation_model = attributes[:'reservation_model']
181
+ else
182
+ self.reservation_model = nil
183
+ end
184
+
185
+ if attributes.key?(:'initial_invoice_model')
186
+ self.initial_invoice_model = attributes[:'initial_invoice_model']
187
+ end
188
+
189
+ if attributes.key?(:'start_date_time')
190
+ self.start_date_time = attributes[:'start_date_time']
191
+ else
192
+ self.start_date_time = nil
193
+ end
194
+
195
+ if attributes.key?(:'end_date_time')
196
+ self.end_date_time = attributes[:'end_date_time']
197
+ end
198
+
199
+ if attributes.key?(:'last_renewal_date_time')
200
+ self.last_renewal_date_time = attributes[:'last_renewal_date_time']
201
+ end
202
+
203
+ if attributes.key?(:'next_renewal_date_time')
204
+ self.next_renewal_date_time = attributes[:'next_renewal_date_time']
205
+ end
206
+
207
+ if attributes.key?(:'auto_renew')
208
+ self.auto_renew = attributes[:'auto_renew']
209
+ else
210
+ self.auto_renew = nil
211
+ end
212
+
213
+ if attributes.key?(:'sku')
214
+ self.sku = attributes[:'sku']
215
+ else
216
+ self.sku = nil
217
+ end
218
+
219
+ if attributes.key?(:'price')
220
+ self.price = attributes[:'price']
221
+ else
222
+ self.price = nil
223
+ end
224
+
225
+ if attributes.key?(:'price_unit')
226
+ self.price_unit = attributes[:'price_unit']
227
+ else
228
+ self.price_unit = nil
229
+ end
230
+
231
+ if attributes.key?(:'assigned_resource_id')
232
+ self.assigned_resource_id = attributes[:'assigned_resource_id']
233
+ end
234
+
235
+ if attributes.key?(:'next_billing_date')
236
+ self.next_billing_date = attributes[:'next_billing_date']
237
+ end
238
+ end
239
+
240
+ # Show invalid properties with the reasons. Usually used together with valid?
241
+ # @return Array for valid properties with the reasons
242
+ def list_invalid_properties
243
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
244
+ invalid_properties = Array.new
245
+ if @id.nil?
246
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
247
+ end
248
+
249
+ if @product_code.nil?
250
+ invalid_properties.push('invalid value for "product_code", product_code cannot be nil.')
251
+ end
252
+
253
+ if @product_category.nil?
254
+ invalid_properties.push('invalid value for "product_category", product_category cannot be nil.')
255
+ end
256
+
257
+ if @location.nil?
258
+ invalid_properties.push('invalid value for "location", location cannot be nil.')
259
+ end
260
+
261
+ if @reservation_model.nil?
262
+ invalid_properties.push('invalid value for "reservation_model", reservation_model cannot be nil.')
263
+ end
264
+
265
+ if @start_date_time.nil?
266
+ invalid_properties.push('invalid value for "start_date_time", start_date_time cannot be nil.')
267
+ end
268
+
269
+ if @auto_renew.nil?
270
+ invalid_properties.push('invalid value for "auto_renew", auto_renew cannot be nil.')
271
+ end
272
+
273
+ if @sku.nil?
274
+ invalid_properties.push('invalid value for "sku", sku cannot be nil.')
275
+ end
276
+
277
+ if @price.nil?
278
+ invalid_properties.push('invalid value for "price", price cannot be nil.')
279
+ end
280
+
281
+ if @price_unit.nil?
282
+ invalid_properties.push('invalid value for "price_unit", price_unit cannot be nil.')
283
+ end
284
+
285
+ invalid_properties
286
+ end
287
+
288
+ # Check to see if the all the properties in the model are valid
289
+ # @return true if the model is valid
290
+ def valid?
291
+ warn '[DEPRECATED] the `valid?` method is obsolete'
292
+ return false if @id.nil?
293
+ return false if @product_code.nil?
294
+ return false if @product_category.nil?
295
+ product_category_validator = EnumAttributeValidator.new('String', ["server", "bandwidth", "operating-system"])
296
+ return false unless product_category_validator.valid?(@product_category)
297
+ return false if @location.nil?
298
+ return false if @reservation_model.nil?
299
+ return false if @start_date_time.nil?
300
+ return false if @auto_renew.nil?
301
+ return false if @sku.nil?
302
+ return false if @price.nil?
303
+ return false if @price_unit.nil?
304
+ true
305
+ end
306
+
307
+ # Custom attribute writer method checking allowed values (enum).
308
+ # @param [Object] product_category Object to be assigned
309
+ def product_category=(product_category)
310
+ validator = EnumAttributeValidator.new('String', ["server", "bandwidth", "operating-system"])
311
+ unless validator.valid?(product_category)
312
+ fail ArgumentError, "invalid value for \"product_category\", must be one of #{validator.allowable_values}."
313
+ end
314
+ @product_category = product_category
315
+ end
316
+
317
+ # Checks equality by comparing each attribute.
318
+ # @param [Object] Object to be compared
319
+ def ==(o)
320
+ return true if self.equal?(o)
321
+ self.class == o.class &&
322
+ id == o.id &&
323
+ product_code == o.product_code &&
324
+ product_category == o.product_category &&
325
+ location == o.location &&
326
+ reservation_model == o.reservation_model &&
327
+ initial_invoice_model == o.initial_invoice_model &&
328
+ start_date_time == o.start_date_time &&
329
+ end_date_time == o.end_date_time &&
330
+ last_renewal_date_time == o.last_renewal_date_time &&
331
+ next_renewal_date_time == o.next_renewal_date_time &&
332
+ auto_renew == o.auto_renew &&
333
+ sku == o.sku &&
334
+ price == o.price &&
335
+ price_unit == o.price_unit &&
336
+ assigned_resource_id == o.assigned_resource_id &&
337
+ next_billing_date == o.next_billing_date
338
+ end
339
+
340
+ # @see the `==` method
341
+ # @param [Object] Object to be compared
342
+ def eql?(o)
343
+ self == o
344
+ end
345
+
346
+ # Calculates hash code according to all attributes.
347
+ # @return [Integer] Hash code
348
+ def hash
349
+ [id, product_code, product_category, location, reservation_model, initial_invoice_model, start_date_time, end_date_time, last_renewal_date_time, next_renewal_date_time, auto_renew, sku, price, price_unit, assigned_resource_id, next_billing_date].hash
350
+ end
351
+
352
+ # Builds the object from hash
353
+ # @param [Hash] attributes Model attributes in the form of hash
354
+ # @return [Object] Returns the model itself
355
+ def self.build_from_hash(attributes)
356
+ return nil unless attributes.is_a?(Hash)
357
+ attributes = attributes.transform_keys(&:to_sym)
358
+ transformed_hash = {}
359
+ openapi_types.each_pair do |key, type|
360
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
361
+ transformed_hash["#{key}"] = nil
362
+ elsif type =~ /\AArray<(.*)>/i
363
+ # check to ensure the input is an array given that the attribute
364
+ # is documented as an array but the input is not
365
+ if attributes[attribute_map[key]].is_a?(Array)
366
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
367
+ end
368
+ elsif !attributes[attribute_map[key]].nil?
369
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
370
+ end
371
+ end
372
+ new(transformed_hash)
373
+ end
374
+
375
+ # Deserializes the data based on type
376
+ # @param string type Data type
377
+ # @param string value Value to be deserialized
378
+ # @return [Object] Deserialized data
379
+ def self._deserialize(type, value)
380
+ case type.to_sym
381
+ when :Time
382
+ Time.parse(value)
383
+ when :Date
384
+ Date.parse(value)
385
+ when :String
386
+ value.to_s
387
+ when :Integer
388
+ value.to_i
389
+ when :Float
390
+ value.to_f
391
+ when :Boolean
392
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
393
+ true
394
+ else
395
+ false
396
+ end
397
+ when :Object
398
+ # generic object (usually a Hash), return directly
399
+ value
400
+ when /\AArray<(?<inner_type>.+)>\z/
401
+ inner_type = Regexp.last_match[:inner_type]
402
+ value.map { |v| _deserialize(inner_type, v) }
403
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
404
+ k_type = Regexp.last_match[:k_type]
405
+ v_type = Regexp.last_match[:v_type]
406
+ {}.tap do |hash|
407
+ value.each do |k, v|
408
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
409
+ end
410
+ end
411
+ else # model
412
+ # models (e.g. Pet) or oneOf
413
+ klass = BillingApi.const_get(type)
414
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
415
+ end
416
+ end
417
+
418
+ # Returns the string representation of the object
419
+ # @return [String] String presentation of the object
420
+ def to_s
421
+ to_hash.to_s
422
+ end
423
+
424
+ # to_body is an alias to to_hash (backward compatibility)
425
+ # @return [Hash] Returns the object in the form of hash
426
+ def to_body
427
+ to_hash
428
+ end
429
+
430
+ # Returns the object in the form of hash
431
+ # @return [Hash] Returns the object in the form of hash
432
+ def to_hash
433
+ hash = {}
434
+ self.class.attribute_map.each_pair do |attr, param|
435
+ value = self.send(attr)
436
+ if value.nil?
437
+ is_nullable = self.class.openapi_nullable.include?(attr)
438
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
439
+ end
440
+
441
+ hash[param] = _to_hash(value)
442
+ end
443
+ hash
444
+ end
445
+
446
+ # Outputs non-array value in the form of hash
447
+ # For object, use to_hash. Otherwise, just return the value
448
+ # @param [Object] value Any valid value
449
+ # @return [Hash] Returns the value in the form of hash
450
+ def _to_hash(value)
451
+ if value.is_a?(Array)
452
+ value.compact.map { |v| _to_hash(v) }
453
+ elsif value.is_a?(Hash)
454
+ {}.tap do |hash|
455
+ value.each { |k, v| hash[k] = _to_hash(v) }
456
+ end
457
+ elsif value.respond_to? :to_hash
458
+ value.to_hash
459
+ else
460
+ value
461
+ end
462
+ end
463
+
464
+ end
465
+
466
+ end
@@ -0,0 +1,215 @@
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
+ # Disabling auto-renewal for reservation request.
18
+ class ReservationAutoRenewDisableRequest
19
+ attr_accessor :auto_renew_disable_reason
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'auto_renew_disable_reason' => :'autoRenewDisableReason'
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'auto_renew_disable_reason' => :'String'
37
+ }
38
+ end
39
+
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ ])
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BillingApi::ReservationAutoRenewDisableRequest` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BillingApi::ReservationAutoRenewDisableRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'auto_renew_disable_reason')
62
+ self.auto_renew_disable_reason = attributes[:'auto_renew_disable_reason']
63
+ end
64
+ end
65
+
66
+ # Show invalid properties with the reasons. Usually used together with valid?
67
+ # @return Array for valid properties with the reasons
68
+ def list_invalid_properties
69
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
70
+ invalid_properties = Array.new
71
+ invalid_properties
72
+ end
73
+
74
+ # Check to see if the all the properties in the model are valid
75
+ # @return true if the model is valid
76
+ def valid?
77
+ warn '[DEPRECATED] the `valid?` method is obsolete'
78
+ true
79
+ end
80
+
81
+ # Checks equality by comparing each attribute.
82
+ # @param [Object] Object to be compared
83
+ def ==(o)
84
+ return true if self.equal?(o)
85
+ self.class == o.class &&
86
+ auto_renew_disable_reason == o.auto_renew_disable_reason
87
+ end
88
+
89
+ # @see the `==` method
90
+ # @param [Object] Object to be compared
91
+ def eql?(o)
92
+ self == o
93
+ end
94
+
95
+ # Calculates hash code according to all attributes.
96
+ # @return [Integer] Hash code
97
+ def hash
98
+ [auto_renew_disable_reason].hash
99
+ end
100
+
101
+ # Builds the object from hash
102
+ # @param [Hash] attributes Model attributes in the form of hash
103
+ # @return [Object] Returns the model itself
104
+ def self.build_from_hash(attributes)
105
+ return nil unless attributes.is_a?(Hash)
106
+ attributes = attributes.transform_keys(&:to_sym)
107
+ transformed_hash = {}
108
+ openapi_types.each_pair do |key, type|
109
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
110
+ transformed_hash["#{key}"] = nil
111
+ elsif type =~ /\AArray<(.*)>/i
112
+ # check to ensure the input is an array given that the attribute
113
+ # is documented as an array but the input is not
114
+ if attributes[attribute_map[key]].is_a?(Array)
115
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
116
+ end
117
+ elsif !attributes[attribute_map[key]].nil?
118
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
119
+ end
120
+ end
121
+ new(transformed_hash)
122
+ end
123
+
124
+ # Deserializes the data based on type
125
+ # @param string type Data type
126
+ # @param string value Value to be deserialized
127
+ # @return [Object] Deserialized data
128
+ def self._deserialize(type, value)
129
+ case type.to_sym
130
+ when :Time
131
+ Time.parse(value)
132
+ when :Date
133
+ Date.parse(value)
134
+ when :String
135
+ value.to_s
136
+ when :Integer
137
+ value.to_i
138
+ when :Float
139
+ value.to_f
140
+ when :Boolean
141
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
142
+ true
143
+ else
144
+ false
145
+ end
146
+ when :Object
147
+ # generic object (usually a Hash), return directly
148
+ value
149
+ when /\AArray<(?<inner_type>.+)>\z/
150
+ inner_type = Regexp.last_match[:inner_type]
151
+ value.map { |v| _deserialize(inner_type, v) }
152
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
153
+ k_type = Regexp.last_match[:k_type]
154
+ v_type = Regexp.last_match[:v_type]
155
+ {}.tap do |hash|
156
+ value.each do |k, v|
157
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
158
+ end
159
+ end
160
+ else # model
161
+ # models (e.g. Pet) or oneOf
162
+ klass = BillingApi.const_get(type)
163
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
164
+ end
165
+ end
166
+
167
+ # Returns the string representation of the object
168
+ # @return [String] String presentation of the object
169
+ def to_s
170
+ to_hash.to_s
171
+ end
172
+
173
+ # to_body is an alias to to_hash (backward compatibility)
174
+ # @return [Hash] Returns the object in the form of hash
175
+ def to_body
176
+ to_hash
177
+ end
178
+
179
+ # Returns the object in the form of hash
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_hash
182
+ hash = {}
183
+ self.class.attribute_map.each_pair do |attr, param|
184
+ value = self.send(attr)
185
+ if value.nil?
186
+ is_nullable = self.class.openapi_nullable.include?(attr)
187
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
188
+ end
189
+
190
+ hash[param] = _to_hash(value)
191
+ end
192
+ hash
193
+ end
194
+
195
+ # Outputs non-array value in the form of hash
196
+ # For object, use to_hash. Otherwise, just return the value
197
+ # @param [Object] value Any valid value
198
+ # @return [Hash] Returns the value in the form of hash
199
+ def _to_hash(value)
200
+ if value.is_a?(Array)
201
+ value.compact.map { |v| _to_hash(v) }
202
+ elsif value.is_a?(Hash)
203
+ {}.tap do |hash|
204
+ value.each { |k, v| hash[k] = _to_hash(v) }
205
+ end
206
+ elsif value.respond_to? :to_hash
207
+ value.to_hash
208
+ else
209
+ value
210
+ end
211
+ end
212
+
213
+ end
214
+
215
+ end