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,397 @@
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
+ # Pricing plan details.
18
+ class PricingPlan
19
+ # The SKU identifying this pricing plan.
20
+ attr_accessor :sku
21
+
22
+ # Description of this pricing plan.
23
+ attr_accessor :sku_description
24
+
25
+ # The code identifying the location.
26
+ attr_accessor :location
27
+
28
+ # The pricing model.
29
+ attr_accessor :pricing_model
30
+
31
+ # The price per unit.
32
+ attr_accessor :price
33
+
34
+ attr_accessor :price_unit
35
+
36
+ attr_accessor :applicable_discounts
37
+
38
+ # Product code of the product this product is correlated with
39
+ attr_accessor :correlated_product_code
40
+
41
+ # Package size per month.
42
+ attr_accessor :package_quantity
43
+
44
+ # Package size unit.
45
+ attr_accessor :package_unit
46
+
47
+ class EnumAttributeValidator
48
+ attr_reader :datatype
49
+ attr_reader :allowable_values
50
+
51
+ def initialize(datatype, allowable_values)
52
+ @allowable_values = allowable_values.map do |value|
53
+ case datatype.to_s
54
+ when /Integer/i
55
+ value.to_i
56
+ when /Float/i
57
+ value.to_f
58
+ else
59
+ value
60
+ end
61
+ end
62
+ end
63
+
64
+ def valid?(value)
65
+ !value || allowable_values.include?(value)
66
+ end
67
+ end
68
+
69
+ # Attribute mapping from ruby-style variable name to JSON key.
70
+ def self.attribute_map
71
+ {
72
+ :'sku' => :'sku',
73
+ :'sku_description' => :'skuDescription',
74
+ :'location' => :'location',
75
+ :'pricing_model' => :'pricingModel',
76
+ :'price' => :'price',
77
+ :'price_unit' => :'priceUnit',
78
+ :'applicable_discounts' => :'applicableDiscounts',
79
+ :'correlated_product_code' => :'correlatedProductCode',
80
+ :'package_quantity' => :'packageQuantity',
81
+ :'package_unit' => :'packageUnit'
82
+ }
83
+ end
84
+
85
+ # Returns all the JSON keys this model knows about
86
+ def self.acceptable_attributes
87
+ attribute_map.values
88
+ end
89
+
90
+ # Attribute type mapping.
91
+ def self.openapi_types
92
+ {
93
+ :'sku' => :'String',
94
+ :'sku_description' => :'String',
95
+ :'location' => :'String',
96
+ :'pricing_model' => :'String',
97
+ :'price' => :'Float',
98
+ :'price_unit' => :'PriceUnitEnum',
99
+ :'applicable_discounts' => :'ApplicableDiscounts',
100
+ :'correlated_product_code' => :'String',
101
+ :'package_quantity' => :'Float',
102
+ :'package_unit' => :'String'
103
+ }
104
+ end
105
+
106
+ # List of attributes with nullable: true
107
+ def self.openapi_nullable
108
+ Set.new([
109
+ ])
110
+ end
111
+
112
+ # Initializes the object
113
+ # @param [Hash] attributes Model attributes in the form of hash
114
+ def initialize(attributes = {})
115
+ if (!attributes.is_a?(Hash))
116
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BillingApi::PricingPlan` initialize method"
117
+ end
118
+
119
+ # check to see if the attribute exists and convert string to symbol for hash key
120
+ attributes = attributes.each_with_object({}) { |(k, v), h|
121
+ if (!self.class.attribute_map.key?(k.to_sym))
122
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BillingApi::PricingPlan`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
123
+ end
124
+ h[k.to_sym] = v
125
+ }
126
+
127
+ if attributes.key?(:'sku')
128
+ self.sku = attributes[:'sku']
129
+ else
130
+ self.sku = nil
131
+ end
132
+
133
+ if attributes.key?(:'sku_description')
134
+ self.sku_description = attributes[:'sku_description']
135
+ end
136
+
137
+ if attributes.key?(:'location')
138
+ self.location = attributes[:'location']
139
+ else
140
+ self.location = nil
141
+ end
142
+
143
+ if attributes.key?(:'pricing_model')
144
+ self.pricing_model = attributes[:'pricing_model']
145
+ else
146
+ self.pricing_model = nil
147
+ end
148
+
149
+ if attributes.key?(:'price')
150
+ self.price = attributes[:'price']
151
+ else
152
+ self.price = nil
153
+ end
154
+
155
+ if attributes.key?(:'price_unit')
156
+ self.price_unit = attributes[:'price_unit']
157
+ else
158
+ self.price_unit = nil
159
+ end
160
+
161
+ if attributes.key?(:'applicable_discounts')
162
+ self.applicable_discounts = attributes[:'applicable_discounts']
163
+ end
164
+
165
+ if attributes.key?(:'correlated_product_code')
166
+ self.correlated_product_code = attributes[:'correlated_product_code']
167
+ end
168
+
169
+ if attributes.key?(:'package_quantity')
170
+ self.package_quantity = attributes[:'package_quantity']
171
+ end
172
+
173
+ if attributes.key?(:'package_unit')
174
+ self.package_unit = attributes[:'package_unit']
175
+ end
176
+ end
177
+
178
+ # Show invalid properties with the reasons. Usually used together with valid?
179
+ # @return Array for valid properties with the reasons
180
+ def list_invalid_properties
181
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
182
+ invalid_properties = Array.new
183
+ if @sku.nil?
184
+ invalid_properties.push('invalid value for "sku", sku cannot be nil.')
185
+ end
186
+
187
+ if @location.nil?
188
+ invalid_properties.push('invalid value for "location", location cannot be nil.')
189
+ end
190
+
191
+ if @pricing_model.nil?
192
+ invalid_properties.push('invalid value for "pricing_model", pricing_model cannot be nil.')
193
+ end
194
+
195
+ if @price.nil?
196
+ invalid_properties.push('invalid value for "price", price cannot be nil.')
197
+ end
198
+
199
+ if @price_unit.nil?
200
+ invalid_properties.push('invalid value for "price_unit", price_unit cannot be nil.')
201
+ end
202
+
203
+ invalid_properties
204
+ end
205
+
206
+ # Check to see if the all the properties in the model are valid
207
+ # @return true if the model is valid
208
+ def valid?
209
+ warn '[DEPRECATED] the `valid?` method is obsolete'
210
+ return false if @sku.nil?
211
+ return false if @location.nil?
212
+ location_validator = EnumAttributeValidator.new('String', ["PHX", "ASH", "NLD", "SGP", "CHI", "SEA", "AUS", "GLOBAL"])
213
+ return false unless location_validator.valid?(@location)
214
+ return false if @pricing_model.nil?
215
+ pricing_model_validator = EnumAttributeValidator.new('String', ["HOURLY", "METERED", "ONE_MONTH_RESERVATION", "TWELVE_MONTHS_RESERVATION", "TWENTY_FOUR_MONTHS_RESERVATION", "THIRTY_SIX_MONTHS_RESERVATION", "MONTHLY_PACKAGE", "FREE_TIER"])
216
+ return false unless pricing_model_validator.valid?(@pricing_model)
217
+ return false if @price.nil?
218
+ return false if @price_unit.nil?
219
+ package_unit_validator = EnumAttributeValidator.new('String', ["GB", "TB"])
220
+ return false unless package_unit_validator.valid?(@package_unit)
221
+ true
222
+ end
223
+
224
+ # Custom attribute writer method checking allowed values (enum).
225
+ # @param [Object] location Object to be assigned
226
+ def location=(location)
227
+ validator = EnumAttributeValidator.new('String', ["PHX", "ASH", "NLD", "SGP", "CHI", "SEA", "AUS", "GLOBAL"])
228
+ unless validator.valid?(location)
229
+ fail ArgumentError, "invalid value for \"location\", must be one of #{validator.allowable_values}."
230
+ end
231
+ @location = location
232
+ end
233
+
234
+ # Custom attribute writer method checking allowed values (enum).
235
+ # @param [Object] pricing_model Object to be assigned
236
+ def pricing_model=(pricing_model)
237
+ validator = EnumAttributeValidator.new('String', ["HOURLY", "METERED", "ONE_MONTH_RESERVATION", "TWELVE_MONTHS_RESERVATION", "TWENTY_FOUR_MONTHS_RESERVATION", "THIRTY_SIX_MONTHS_RESERVATION", "MONTHLY_PACKAGE", "FREE_TIER"])
238
+ unless validator.valid?(pricing_model)
239
+ fail ArgumentError, "invalid value for \"pricing_model\", must be one of #{validator.allowable_values}."
240
+ end
241
+ @pricing_model = pricing_model
242
+ end
243
+
244
+ # Custom attribute writer method checking allowed values (enum).
245
+ # @param [Object] package_unit Object to be assigned
246
+ def package_unit=(package_unit)
247
+ validator = EnumAttributeValidator.new('String', ["GB", "TB"])
248
+ unless validator.valid?(package_unit)
249
+ fail ArgumentError, "invalid value for \"package_unit\", must be one of #{validator.allowable_values}."
250
+ end
251
+ @package_unit = package_unit
252
+ end
253
+
254
+ # Checks equality by comparing each attribute.
255
+ # @param [Object] Object to be compared
256
+ def ==(o)
257
+ return true if self.equal?(o)
258
+ self.class == o.class &&
259
+ sku == o.sku &&
260
+ sku_description == o.sku_description &&
261
+ location == o.location &&
262
+ pricing_model == o.pricing_model &&
263
+ price == o.price &&
264
+ price_unit == o.price_unit &&
265
+ applicable_discounts == o.applicable_discounts &&
266
+ correlated_product_code == o.correlated_product_code &&
267
+ package_quantity == o.package_quantity &&
268
+ package_unit == o.package_unit
269
+ end
270
+
271
+ # @see the `==` method
272
+ # @param [Object] Object to be compared
273
+ def eql?(o)
274
+ self == o
275
+ end
276
+
277
+ # Calculates hash code according to all attributes.
278
+ # @return [Integer] Hash code
279
+ def hash
280
+ [sku, sku_description, location, pricing_model, price, price_unit, applicable_discounts, correlated_product_code, package_quantity, package_unit].hash
281
+ end
282
+
283
+ # Builds the object from hash
284
+ # @param [Hash] attributes Model attributes in the form of hash
285
+ # @return [Object] Returns the model itself
286
+ def self.build_from_hash(attributes)
287
+ return nil unless attributes.is_a?(Hash)
288
+ attributes = attributes.transform_keys(&:to_sym)
289
+ transformed_hash = {}
290
+ openapi_types.each_pair do |key, type|
291
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
292
+ transformed_hash["#{key}"] = nil
293
+ elsif type =~ /\AArray<(.*)>/i
294
+ # check to ensure the input is an array given that the attribute
295
+ # is documented as an array but the input is not
296
+ if attributes[attribute_map[key]].is_a?(Array)
297
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
298
+ end
299
+ elsif !attributes[attribute_map[key]].nil?
300
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
301
+ end
302
+ end
303
+ new(transformed_hash)
304
+ end
305
+
306
+ # Deserializes the data based on type
307
+ # @param string type Data type
308
+ # @param string value Value to be deserialized
309
+ # @return [Object] Deserialized data
310
+ def self._deserialize(type, value)
311
+ case type.to_sym
312
+ when :Time
313
+ Time.parse(value)
314
+ when :Date
315
+ Date.parse(value)
316
+ when :String
317
+ value.to_s
318
+ when :Integer
319
+ value.to_i
320
+ when :Float
321
+ value.to_f
322
+ when :Boolean
323
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
324
+ true
325
+ else
326
+ false
327
+ end
328
+ when :Object
329
+ # generic object (usually a Hash), return directly
330
+ value
331
+ when /\AArray<(?<inner_type>.+)>\z/
332
+ inner_type = Regexp.last_match[:inner_type]
333
+ value.map { |v| _deserialize(inner_type, v) }
334
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
335
+ k_type = Regexp.last_match[:k_type]
336
+ v_type = Regexp.last_match[:v_type]
337
+ {}.tap do |hash|
338
+ value.each do |k, v|
339
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
340
+ end
341
+ end
342
+ else # model
343
+ # models (e.g. Pet) or oneOf
344
+ klass = BillingApi.const_get(type)
345
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
346
+ end
347
+ end
348
+
349
+ # Returns the string representation of the object
350
+ # @return [String] String presentation of the object
351
+ def to_s
352
+ to_hash.to_s
353
+ end
354
+
355
+ # to_body is an alias to to_hash (backward compatibility)
356
+ # @return [Hash] Returns the object in the form of hash
357
+ def to_body
358
+ to_hash
359
+ end
360
+
361
+ # Returns the object in the form of hash
362
+ # @return [Hash] Returns the object in the form of hash
363
+ def to_hash
364
+ hash = {}
365
+ self.class.attribute_map.each_pair do |attr, param|
366
+ value = self.send(attr)
367
+ if value.nil?
368
+ is_nullable = self.class.openapi_nullable.include?(attr)
369
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
370
+ end
371
+
372
+ hash[param] = _to_hash(value)
373
+ end
374
+ hash
375
+ end
376
+
377
+ # Outputs non-array value in the form of hash
378
+ # For object, use to_hash. Otherwise, just return the value
379
+ # @param [Object] value Any valid value
380
+ # @return [Hash] Returns the value in the form of hash
381
+ def _to_hash(value)
382
+ if value.is_a?(Array)
383
+ value.compact.map { |v| _to_hash(v) }
384
+ elsif value.is_a?(Hash)
385
+ {}.tap do |hash|
386
+ value.each { |k, v| hash[k] = _to_hash(v) }
387
+ end
388
+ elsif value.respond_to? :to_hash
389
+ value.to_hash
390
+ else
391
+ value
392
+ end
393
+ end
394
+
395
+ end
396
+
397
+ end
@@ -0,0 +1,252 @@
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
+ # Product details
18
+ class Product
19
+ # The code identifying the product. This code has significant across all locations.
20
+ attr_accessor :product_code
21
+
22
+ # The product category.
23
+ attr_accessor :product_category
24
+
25
+ # The pricing plans available for this product.
26
+ attr_accessor :plans
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'product_code' => :'productCode',
32
+ :'product_category' => :'productCategory',
33
+ :'plans' => :'plans'
34
+ }
35
+ end
36
+
37
+ # Returns all the JSON keys this model knows about
38
+ def self.acceptable_attributes
39
+ attribute_map.values
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.openapi_types
44
+ {
45
+ :'product_code' => :'String',
46
+ :'product_category' => :'String',
47
+ :'plans' => :'Array<PricingPlan>'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BillingApi::Product` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BillingApi::Product`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'product_code')
73
+ self.product_code = attributes[:'product_code']
74
+ else
75
+ self.product_code = nil
76
+ end
77
+
78
+ if attributes.key?(:'product_category')
79
+ self.product_category = attributes[:'product_category']
80
+ else
81
+ self.product_category = nil
82
+ end
83
+
84
+ if attributes.key?(:'plans')
85
+ if (value = attributes[:'plans']).is_a?(Array)
86
+ self.plans = value
87
+ end
88
+ end
89
+ end
90
+
91
+ # Show invalid properties with the reasons. Usually used together with valid?
92
+ # @return Array for valid properties with the reasons
93
+ def list_invalid_properties
94
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
95
+ invalid_properties = Array.new
96
+ if @product_code.nil?
97
+ invalid_properties.push('invalid value for "product_code", product_code cannot be nil.')
98
+ end
99
+
100
+ if @product_category.nil?
101
+ invalid_properties.push('invalid value for "product_category", product_category cannot be nil.')
102
+ end
103
+
104
+ invalid_properties
105
+ end
106
+
107
+ # Check to see if the all the properties in the model are valid
108
+ # @return true if the model is valid
109
+ def valid?
110
+ warn '[DEPRECATED] the `valid?` method is obsolete'
111
+ return false if @product_code.nil?
112
+ return false if @product_category.nil?
113
+ true
114
+ end
115
+
116
+ # Checks equality by comparing each attribute.
117
+ # @param [Object] Object to be compared
118
+ def ==(o)
119
+ return true if self.equal?(o)
120
+ self.class == o.class &&
121
+ product_code == o.product_code &&
122
+ product_category == o.product_category &&
123
+ plans == o.plans
124
+ end
125
+
126
+ # @see the `==` method
127
+ # @param [Object] Object to be compared
128
+ def eql?(o)
129
+ self == o
130
+ end
131
+
132
+ # Calculates hash code according to all attributes.
133
+ # @return [Integer] Hash code
134
+ def hash
135
+ [product_code, product_category, plans].hash
136
+ end
137
+
138
+ # Builds the object from hash
139
+ # @param [Hash] attributes Model attributes in the form of hash
140
+ # @return [Object] Returns the model itself
141
+ def self.build_from_hash(attributes)
142
+ return nil unless attributes.is_a?(Hash)
143
+ attributes = attributes.transform_keys(&:to_sym)
144
+ transformed_hash = {}
145
+ openapi_types.each_pair do |key, type|
146
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
147
+ transformed_hash["#{key}"] = nil
148
+ elsif type =~ /\AArray<(.*)>/i
149
+ # check to ensure the input is an array given that the attribute
150
+ # is documented as an array but the input is not
151
+ if attributes[attribute_map[key]].is_a?(Array)
152
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
153
+ end
154
+ elsif !attributes[attribute_map[key]].nil?
155
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
156
+ end
157
+ end
158
+ new(transformed_hash)
159
+ end
160
+
161
+ # Deserializes the data based on type
162
+ # @param string type Data type
163
+ # @param string value Value to be deserialized
164
+ # @return [Object] Deserialized data
165
+ def self._deserialize(type, value)
166
+ case type.to_sym
167
+ when :Time
168
+ Time.parse(value)
169
+ when :Date
170
+ Date.parse(value)
171
+ when :String
172
+ value.to_s
173
+ when :Integer
174
+ value.to_i
175
+ when :Float
176
+ value.to_f
177
+ when :Boolean
178
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
179
+ true
180
+ else
181
+ false
182
+ end
183
+ when :Object
184
+ # generic object (usually a Hash), return directly
185
+ value
186
+ when /\AArray<(?<inner_type>.+)>\z/
187
+ inner_type = Regexp.last_match[:inner_type]
188
+ value.map { |v| _deserialize(inner_type, v) }
189
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
190
+ k_type = Regexp.last_match[:k_type]
191
+ v_type = Regexp.last_match[:v_type]
192
+ {}.tap do |hash|
193
+ value.each do |k, v|
194
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
195
+ end
196
+ end
197
+ else # model
198
+ # models (e.g. Pet) or oneOf
199
+ klass = BillingApi.const_get(type)
200
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
201
+ end
202
+ end
203
+
204
+ # Returns the string representation of the object
205
+ # @return [String] String presentation of the object
206
+ def to_s
207
+ to_hash.to_s
208
+ end
209
+
210
+ # to_body is an alias to to_hash (backward compatibility)
211
+ # @return [Hash] Returns the object in the form of hash
212
+ def to_body
213
+ to_hash
214
+ end
215
+
216
+ # Returns the object in the form of hash
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_hash
219
+ hash = {}
220
+ self.class.attribute_map.each_pair do |attr, param|
221
+ value = self.send(attr)
222
+ if value.nil?
223
+ is_nullable = self.class.openapi_nullable.include?(attr)
224
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
225
+ end
226
+
227
+ hash[param] = _to_hash(value)
228
+ end
229
+ hash
230
+ end
231
+
232
+ # Outputs non-array value in the form of hash
233
+ # For object, use to_hash. Otherwise, just return the value
234
+ # @param [Object] value Any valid value
235
+ # @return [Hash] Returns the value in the form of hash
236
+ def _to_hash(value)
237
+ if value.is_a?(Array)
238
+ value.compact.map { |v| _to_hash(v) }
239
+ elsif value.is_a?(Hash)
240
+ {}.tap do |hash|
241
+ value.each { |k, v| hash[k] = _to_hash(v) }
242
+ end
243
+ elsif value.respond_to? :to_hash
244
+ value.to_hash
245
+ else
246
+ value
247
+ end
248
+ end
249
+
250
+ end
251
+
252
+ end