pnap_billing_api 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/VERSION +1 -1
- data/docs/BandwidthRecord.md +4 -2
- data/docs/CreditDetails.md +49 -0
- data/docs/CreditDetailsBase.md +20 -0
- data/docs/CreditTypeEnum.md +15 -0
- data/docs/DiscountDetails.md +2 -2
- data/docs/DiscountTypeEnum.md +15 -0
- data/docs/GpuConfigurationMetadata.md +20 -0
- data/docs/OperatingSystemRecord.md +4 -2
- data/docs/PricingPlan.md +2 -2
- data/docs/PromoCreditDetails.md +24 -0
- data/docs/PublicSubnetRecord.md +4 -2
- data/docs/RatedUsageProductCategoryEnum.md +15 -0
- data/docs/RatedUsageRecord.md +5 -3
- data/docs/ReservationAutoRenewDisableRequest.md +1 -1
- data/docs/ServerProductMetadata.md +3 -1
- data/docs/ServerRecord.md +4 -2
- data/docs/StorageRecord.md +4 -2
- data/docs/SystemCreditCauseEnum.md +15 -0
- data/docs/SystemCreditDetails.md +22 -0
- data/lib/pnap_billing_api/models/bandwidth_record.rb +13 -15
- data/lib/pnap_billing_api/models/credit_details.rb +105 -0
- data/lib/pnap_billing_api/models/credit_details_base.rb +261 -0
- data/lib/pnap_billing_api/models/credit_type_enum.rb +40 -0
- data/lib/pnap_billing_api/models/discount_details.rb +1 -14
- data/lib/pnap_billing_api/models/discount_type_enum.rb +41 -0
- data/lib/pnap_billing_api/models/gpu_configuration_metadata.rb +226 -0
- data/lib/pnap_billing_api/models/operating_system_record.rb +13 -15
- data/lib/pnap_billing_api/models/promo_credit_details.rb +301 -0
- data/lib/pnap_billing_api/models/public_subnet_record.rb +13 -15
- data/lib/pnap_billing_api/models/rated_usage_product_category_enum.rb +43 -0
- data/lib/pnap_billing_api/models/rated_usage_record.rb +16 -18
- data/lib/pnap_billing_api/models/server_product_metadata.rb +16 -4
- data/lib/pnap_billing_api/models/server_record.rb +13 -15
- data/lib/pnap_billing_api/models/storage_record.rb +13 -15
- data/lib/pnap_billing_api/models/system_credit_cause_enum.rb +39 -0
- data/lib/pnap_billing_api/models/system_credit_details.rb +283 -0
- data/lib/pnap_billing_api.rb +9 -0
- data/spec/models/bandwidth_record_spec.rb +6 -4
- data/spec/models/credit_details_base_spec.rb +42 -0
- data/spec/models/credit_details_spec.rb +32 -0
- data/spec/models/credit_type_enum_spec.rb +30 -0
- data/spec/models/discount_details_spec.rb +0 -4
- data/spec/models/discount_type_enum_spec.rb +30 -0
- data/spec/models/gpu_configuration_metadata_spec.rb +42 -0
- data/spec/models/operating_system_record_spec.rb +6 -4
- data/spec/models/promo_credit_details_spec.rb +54 -0
- data/spec/models/public_subnet_record_spec.rb +6 -4
- data/spec/models/rated_usage_product_category_enum_spec.rb +30 -0
- data/spec/models/rated_usage_record_spec.rb +6 -4
- data/spec/models/server_product_metadata_spec.rb +6 -0
- data/spec/models/server_record_spec.rb +6 -4
- data/spec/models/storage_record_spec.rb +6 -4
- data/spec/models/system_credit_cause_enum_spec.rb +30 -0
- data/spec/models/system_credit_details_spec.rb +48 -0
- metadata +67 -31
@@ -0,0 +1,226 @@
|
|
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
|
+
# GPU configuration details.
|
18
|
+
class GpuConfigurationMetadata
|
19
|
+
# GPU card count.
|
20
|
+
attr_accessor :count
|
21
|
+
|
22
|
+
# GPU name.
|
23
|
+
attr_accessor :name
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'count' => :'count',
|
29
|
+
:'name' => :'name'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns all the JSON keys this model knows about
|
34
|
+
def self.acceptable_attributes
|
35
|
+
attribute_map.values
|
36
|
+
end
|
37
|
+
|
38
|
+
# Attribute type mapping.
|
39
|
+
def self.openapi_types
|
40
|
+
{
|
41
|
+
:'count' => :'Float',
|
42
|
+
:'name' => :'String'
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
# List of attributes with nullable: true
|
47
|
+
def self.openapi_nullable
|
48
|
+
Set.new([
|
49
|
+
])
|
50
|
+
end
|
51
|
+
|
52
|
+
# Initializes the object
|
53
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
54
|
+
def initialize(attributes = {})
|
55
|
+
if (!attributes.is_a?(Hash))
|
56
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `BillingApi::GpuConfigurationMetadata` initialize method"
|
57
|
+
end
|
58
|
+
|
59
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
60
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
61
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
62
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `BillingApi::GpuConfigurationMetadata`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
63
|
+
end
|
64
|
+
h[k.to_sym] = v
|
65
|
+
}
|
66
|
+
|
67
|
+
if attributes.key?(:'count')
|
68
|
+
self.count = attributes[:'count']
|
69
|
+
end
|
70
|
+
|
71
|
+
if attributes.key?(:'name')
|
72
|
+
self.name = attributes[:'name']
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
77
|
+
# @return Array for valid properties with the reasons
|
78
|
+
def list_invalid_properties
|
79
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
80
|
+
invalid_properties = Array.new
|
81
|
+
invalid_properties
|
82
|
+
end
|
83
|
+
|
84
|
+
# Check to see if the all the properties in the model are valid
|
85
|
+
# @return true if the model is valid
|
86
|
+
def valid?
|
87
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
91
|
+
# Checks equality by comparing each attribute.
|
92
|
+
# @param [Object] Object to be compared
|
93
|
+
def ==(o)
|
94
|
+
return true if self.equal?(o)
|
95
|
+
self.class == o.class &&
|
96
|
+
count == o.count &&
|
97
|
+
name == o.name
|
98
|
+
end
|
99
|
+
|
100
|
+
# @see the `==` method
|
101
|
+
# @param [Object] Object to be compared
|
102
|
+
def eql?(o)
|
103
|
+
self == o
|
104
|
+
end
|
105
|
+
|
106
|
+
# Calculates hash code according to all attributes.
|
107
|
+
# @return [Integer] Hash code
|
108
|
+
def hash
|
109
|
+
[count, name].hash
|
110
|
+
end
|
111
|
+
|
112
|
+
# Builds the object from hash
|
113
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
114
|
+
# @return [Object] Returns the model itself
|
115
|
+
def self.build_from_hash(attributes)
|
116
|
+
return nil unless attributes.is_a?(Hash)
|
117
|
+
attributes = attributes.transform_keys(&:to_sym)
|
118
|
+
transformed_hash = {}
|
119
|
+
openapi_types.each_pair do |key, type|
|
120
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
121
|
+
transformed_hash["#{key}"] = nil
|
122
|
+
elsif type =~ /\AArray<(.*)>/i
|
123
|
+
# check to ensure the input is an array given that the attribute
|
124
|
+
# is documented as an array but the input is not
|
125
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
126
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
127
|
+
end
|
128
|
+
elsif !attributes[attribute_map[key]].nil?
|
129
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
130
|
+
end
|
131
|
+
end
|
132
|
+
new(transformed_hash)
|
133
|
+
end
|
134
|
+
|
135
|
+
# Deserializes the data based on type
|
136
|
+
# @param string type Data type
|
137
|
+
# @param string value Value to be deserialized
|
138
|
+
# @return [Object] Deserialized data
|
139
|
+
def self._deserialize(type, value)
|
140
|
+
case type.to_sym
|
141
|
+
when :Time
|
142
|
+
Time.parse(value)
|
143
|
+
when :Date
|
144
|
+
Date.parse(value)
|
145
|
+
when :String
|
146
|
+
value.to_s
|
147
|
+
when :Integer
|
148
|
+
value.to_i
|
149
|
+
when :Float
|
150
|
+
value.to_f
|
151
|
+
when :Boolean
|
152
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
153
|
+
true
|
154
|
+
else
|
155
|
+
false
|
156
|
+
end
|
157
|
+
when :Object
|
158
|
+
# generic object (usually a Hash), return directly
|
159
|
+
value
|
160
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
161
|
+
inner_type = Regexp.last_match[:inner_type]
|
162
|
+
value.map { |v| _deserialize(inner_type, v) }
|
163
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
164
|
+
k_type = Regexp.last_match[:k_type]
|
165
|
+
v_type = Regexp.last_match[:v_type]
|
166
|
+
{}.tap do |hash|
|
167
|
+
value.each do |k, v|
|
168
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
else # model
|
172
|
+
# models (e.g. Pet) or oneOf
|
173
|
+
klass = BillingApi.const_get(type)
|
174
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
# Returns the string representation of the object
|
179
|
+
# @return [String] String presentation of the object
|
180
|
+
def to_s
|
181
|
+
to_hash.to_s
|
182
|
+
end
|
183
|
+
|
184
|
+
# to_body is an alias to to_hash (backward compatibility)
|
185
|
+
# @return [Hash] Returns the object in the form of hash
|
186
|
+
def to_body
|
187
|
+
to_hash
|
188
|
+
end
|
189
|
+
|
190
|
+
# Returns the object in the form of hash
|
191
|
+
# @return [Hash] Returns the object in the form of hash
|
192
|
+
def to_hash
|
193
|
+
hash = {}
|
194
|
+
self.class.attribute_map.each_pair do |attr, param|
|
195
|
+
value = self.send(attr)
|
196
|
+
if value.nil?
|
197
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
198
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
199
|
+
end
|
200
|
+
|
201
|
+
hash[param] = _to_hash(value)
|
202
|
+
end
|
203
|
+
hash
|
204
|
+
end
|
205
|
+
|
206
|
+
# Outputs non-array value in the form of hash
|
207
|
+
# For object, use to_hash. Otherwise, just return the value
|
208
|
+
# @param [Object] value Any valid value
|
209
|
+
# @return [Hash] Returns the value in the form of hash
|
210
|
+
def _to_hash(value)
|
211
|
+
if value.is_a?(Array)
|
212
|
+
value.compact.map { |v| _to_hash(v) }
|
213
|
+
elsif value.is_a?(Hash)
|
214
|
+
{}.tap do |hash|
|
215
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
216
|
+
end
|
217
|
+
elsif value.respond_to? :to_hash
|
218
|
+
value.to_hash
|
219
|
+
else
|
220
|
+
value
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
@@ -18,7 +18,6 @@ module BillingApi
|
|
18
18
|
# The unique identifier of the rated usage record.
|
19
19
|
attr_accessor :id
|
20
20
|
|
21
|
-
# The category of the product associated with this usage record.
|
22
21
|
attr_accessor :product_category
|
23
22
|
|
24
23
|
# The code identifying the product associated to this usage record.
|
@@ -70,6 +69,8 @@ module BillingApi
|
|
70
69
|
|
71
70
|
attr_accessor :discount_details
|
72
71
|
|
72
|
+
attr_accessor :credit_details
|
73
|
+
|
73
74
|
attr_accessor :metadata
|
74
75
|
|
75
76
|
class EnumAttributeValidator
|
@@ -116,6 +117,7 @@ module BillingApi
|
|
116
117
|
:'correlation_id' => :'correlationId',
|
117
118
|
:'reservation_id' => :'reservationId',
|
118
119
|
:'discount_details' => :'discountDetails',
|
120
|
+
:'credit_details' => :'creditDetails',
|
119
121
|
:'metadata' => :'metadata'
|
120
122
|
}
|
121
123
|
end
|
@@ -129,7 +131,7 @@ module BillingApi
|
|
129
131
|
def self.openapi_types
|
130
132
|
{
|
131
133
|
:'id' => :'String',
|
132
|
-
:'product_category' => :'
|
134
|
+
:'product_category' => :'RatedUsageProductCategoryEnum',
|
133
135
|
:'product_code' => :'String',
|
134
136
|
:'location' => :'LocationEnum',
|
135
137
|
:'year_month' => :'String',
|
@@ -147,6 +149,7 @@ module BillingApi
|
|
147
149
|
:'correlation_id' => :'String',
|
148
150
|
:'reservation_id' => :'String',
|
149
151
|
:'discount_details' => :'DiscountDetails',
|
152
|
+
:'credit_details' => :'Array<CreditDetails>',
|
150
153
|
:'metadata' => :'OperatingSystemDetails'
|
151
154
|
}
|
152
155
|
end
|
@@ -283,6 +286,12 @@ module BillingApi
|
|
283
286
|
self.discount_details = attributes[:'discount_details']
|
284
287
|
end
|
285
288
|
|
289
|
+
if attributes.key?(:'credit_details')
|
290
|
+
if (value = attributes[:'credit_details']).is_a?(Array)
|
291
|
+
self.credit_details = value
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
286
295
|
if attributes.key?(:'metadata')
|
287
296
|
self.metadata = attributes[:'metadata']
|
288
297
|
else
|
@@ -364,8 +373,6 @@ module BillingApi
|
|
364
373
|
warn '[DEPRECATED] the `valid?` method is obsolete'
|
365
374
|
return false if @id.nil?
|
366
375
|
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
376
|
return false if @product_code.nil?
|
370
377
|
return false if @location.nil?
|
371
378
|
return false if @start_date_time.nil?
|
@@ -382,16 +389,6 @@ module BillingApi
|
|
382
389
|
true
|
383
390
|
end
|
384
391
|
|
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
392
|
# Checks equality by comparing each attribute.
|
396
393
|
# @param [Object] Object to be compared
|
397
394
|
def ==(o)
|
@@ -416,6 +413,7 @@ module BillingApi
|
|
416
413
|
correlation_id == o.correlation_id &&
|
417
414
|
reservation_id == o.reservation_id &&
|
418
415
|
discount_details == o.discount_details &&
|
416
|
+
credit_details == o.credit_details &&
|
419
417
|
metadata == o.metadata
|
420
418
|
end
|
421
419
|
|
@@ -428,7 +426,7 @@ module BillingApi
|
|
428
426
|
# Calculates hash code according to all attributes.
|
429
427
|
# @return [Integer] Hash code
|
430
428
|
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
|
429
|
+
[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, credit_details, metadata].hash
|
432
430
|
end
|
433
431
|
|
434
432
|
# Builds the object from hash
|
@@ -0,0 +1,301 @@
|
|
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 PromoCreditDetails
|
18
|
+
# Amount applied.
|
19
|
+
attr_accessor :applied_amount
|
20
|
+
|
21
|
+
attr_accessor :type
|
22
|
+
|
23
|
+
# Coupon id which is the source of the promo credit.
|
24
|
+
attr_accessor :coupon_id
|
25
|
+
|
26
|
+
# Coupon code which is the source of the promo credit.
|
27
|
+
attr_accessor :coupon_code
|
28
|
+
|
29
|
+
class EnumAttributeValidator
|
30
|
+
attr_reader :datatype
|
31
|
+
attr_reader :allowable_values
|
32
|
+
|
33
|
+
def initialize(datatype, allowable_values)
|
34
|
+
@allowable_values = allowable_values.map do |value|
|
35
|
+
case datatype.to_s
|
36
|
+
when /Integer/i
|
37
|
+
value.to_i
|
38
|
+
when /Float/i
|
39
|
+
value.to_f
|
40
|
+
else
|
41
|
+
value
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def valid?(value)
|
47
|
+
!value || allowable_values.include?(value)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
52
|
+
def self.attribute_map
|
53
|
+
{
|
54
|
+
:'applied_amount' => :'appliedAmount',
|
55
|
+
:'type' => :'type',
|
56
|
+
:'coupon_id' => :'couponId',
|
57
|
+
:'coupon_code' => :'couponCode'
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
# Returns all the JSON keys this model knows about
|
62
|
+
def self.acceptable_attributes
|
63
|
+
attribute_map.values
|
64
|
+
end
|
65
|
+
|
66
|
+
# Attribute type mapping.
|
67
|
+
def self.openapi_types
|
68
|
+
{
|
69
|
+
:'applied_amount' => :'Float',
|
70
|
+
:'type' => :'CreditTypeEnum',
|
71
|
+
:'coupon_id' => :'String',
|
72
|
+
:'coupon_code' => :'String'
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
# List of attributes with nullable: true
|
77
|
+
def self.openapi_nullable
|
78
|
+
Set.new([
|
79
|
+
])
|
80
|
+
end
|
81
|
+
|
82
|
+
# List of class defined in allOf (OpenAPI v3)
|
83
|
+
def self.openapi_all_of
|
84
|
+
[
|
85
|
+
:'CreditDetailsBase'
|
86
|
+
]
|
87
|
+
end
|
88
|
+
|
89
|
+
# Initializes the object
|
90
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
91
|
+
def initialize(attributes = {})
|
92
|
+
if (!attributes.is_a?(Hash))
|
93
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `BillingApi::PromoCreditDetails` initialize method"
|
94
|
+
end
|
95
|
+
|
96
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
97
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
98
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
99
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `BillingApi::PromoCreditDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
100
|
+
end
|
101
|
+
h[k.to_sym] = v
|
102
|
+
}
|
103
|
+
|
104
|
+
if attributes.key?(:'applied_amount')
|
105
|
+
self.applied_amount = attributes[:'applied_amount']
|
106
|
+
else
|
107
|
+
self.applied_amount = nil
|
108
|
+
end
|
109
|
+
|
110
|
+
if attributes.key?(:'type')
|
111
|
+
self.type = attributes[:'type']
|
112
|
+
else
|
113
|
+
self.type = nil
|
114
|
+
end
|
115
|
+
|
116
|
+
if attributes.key?(:'coupon_id')
|
117
|
+
self.coupon_id = attributes[:'coupon_id']
|
118
|
+
else
|
119
|
+
self.coupon_id = nil
|
120
|
+
end
|
121
|
+
|
122
|
+
if attributes.key?(:'coupon_code')
|
123
|
+
self.coupon_code = attributes[:'coupon_code']
|
124
|
+
else
|
125
|
+
self.coupon_code = nil
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
130
|
+
# @return Array for valid properties with the reasons
|
131
|
+
def list_invalid_properties
|
132
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
133
|
+
invalid_properties = Array.new
|
134
|
+
if @applied_amount.nil?
|
135
|
+
invalid_properties.push('invalid value for "applied_amount", applied_amount cannot be nil.')
|
136
|
+
end
|
137
|
+
|
138
|
+
if @type.nil?
|
139
|
+
invalid_properties.push('invalid value for "type", type cannot be nil.')
|
140
|
+
end
|
141
|
+
|
142
|
+
if @coupon_id.nil?
|
143
|
+
invalid_properties.push('invalid value for "coupon_id", coupon_id cannot be nil.')
|
144
|
+
end
|
145
|
+
|
146
|
+
if @coupon_code.nil?
|
147
|
+
invalid_properties.push('invalid value for "coupon_code", coupon_code cannot be nil.')
|
148
|
+
end
|
149
|
+
|
150
|
+
invalid_properties
|
151
|
+
end
|
152
|
+
|
153
|
+
# Check to see if the all the properties in the model are valid
|
154
|
+
# @return true if the model is valid
|
155
|
+
def valid?
|
156
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
157
|
+
return false if @applied_amount.nil?
|
158
|
+
return false if @type.nil?
|
159
|
+
return false if @coupon_id.nil?
|
160
|
+
return false if @coupon_code.nil?
|
161
|
+
true
|
162
|
+
end
|
163
|
+
|
164
|
+
# Checks equality by comparing each attribute.
|
165
|
+
# @param [Object] Object to be compared
|
166
|
+
def ==(o)
|
167
|
+
return true if self.equal?(o)
|
168
|
+
self.class == o.class &&
|
169
|
+
applied_amount == o.applied_amount &&
|
170
|
+
type == o.type &&
|
171
|
+
coupon_id == o.coupon_id &&
|
172
|
+
coupon_code == o.coupon_code
|
173
|
+
end
|
174
|
+
|
175
|
+
# @see the `==` method
|
176
|
+
# @param [Object] Object to be compared
|
177
|
+
def eql?(o)
|
178
|
+
self == o
|
179
|
+
end
|
180
|
+
|
181
|
+
# Calculates hash code according to all attributes.
|
182
|
+
# @return [Integer] Hash code
|
183
|
+
def hash
|
184
|
+
[applied_amount, type, coupon_id, coupon_code].hash
|
185
|
+
end
|
186
|
+
|
187
|
+
# Builds the object from hash
|
188
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
189
|
+
# @return [Object] Returns the model itself
|
190
|
+
def self.build_from_hash(attributes)
|
191
|
+
return nil unless attributes.is_a?(Hash)
|
192
|
+
attributes = attributes.transform_keys(&:to_sym)
|
193
|
+
transformed_hash = {}
|
194
|
+
openapi_types.each_pair do |key, type|
|
195
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
196
|
+
transformed_hash["#{key}"] = nil
|
197
|
+
elsif type =~ /\AArray<(.*)>/i
|
198
|
+
# check to ensure the input is an array given that the attribute
|
199
|
+
# is documented as an array but the input is not
|
200
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
201
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
202
|
+
end
|
203
|
+
elsif !attributes[attribute_map[key]].nil?
|
204
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
205
|
+
end
|
206
|
+
end
|
207
|
+
new(transformed_hash)
|
208
|
+
end
|
209
|
+
|
210
|
+
# Deserializes the data based on type
|
211
|
+
# @param string type Data type
|
212
|
+
# @param string value Value to be deserialized
|
213
|
+
# @return [Object] Deserialized data
|
214
|
+
def self._deserialize(type, value)
|
215
|
+
case type.to_sym
|
216
|
+
when :Time
|
217
|
+
Time.parse(value)
|
218
|
+
when :Date
|
219
|
+
Date.parse(value)
|
220
|
+
when :String
|
221
|
+
value.to_s
|
222
|
+
when :Integer
|
223
|
+
value.to_i
|
224
|
+
when :Float
|
225
|
+
value.to_f
|
226
|
+
when :Boolean
|
227
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
228
|
+
true
|
229
|
+
else
|
230
|
+
false
|
231
|
+
end
|
232
|
+
when :Object
|
233
|
+
# generic object (usually a Hash), return directly
|
234
|
+
value
|
235
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
236
|
+
inner_type = Regexp.last_match[:inner_type]
|
237
|
+
value.map { |v| _deserialize(inner_type, v) }
|
238
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
239
|
+
k_type = Regexp.last_match[:k_type]
|
240
|
+
v_type = Regexp.last_match[:v_type]
|
241
|
+
{}.tap do |hash|
|
242
|
+
value.each do |k, v|
|
243
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
else # model
|
247
|
+
# models (e.g. Pet) or oneOf
|
248
|
+
klass = BillingApi.const_get(type)
|
249
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
# Returns the string representation of the object
|
254
|
+
# @return [String] String presentation of the object
|
255
|
+
def to_s
|
256
|
+
to_hash.to_s
|
257
|
+
end
|
258
|
+
|
259
|
+
# to_body is an alias to to_hash (backward compatibility)
|
260
|
+
# @return [Hash] Returns the object in the form of hash
|
261
|
+
def to_body
|
262
|
+
to_hash
|
263
|
+
end
|
264
|
+
|
265
|
+
# Returns the object in the form of hash
|
266
|
+
# @return [Hash] Returns the object in the form of hash
|
267
|
+
def to_hash
|
268
|
+
hash = {}
|
269
|
+
self.class.attribute_map.each_pair do |attr, param|
|
270
|
+
value = self.send(attr)
|
271
|
+
if value.nil?
|
272
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
273
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
274
|
+
end
|
275
|
+
|
276
|
+
hash[param] = _to_hash(value)
|
277
|
+
end
|
278
|
+
hash
|
279
|
+
end
|
280
|
+
|
281
|
+
# Outputs non-array value in the form of hash
|
282
|
+
# For object, use to_hash. Otherwise, just return the value
|
283
|
+
# @param [Object] value Any valid value
|
284
|
+
# @return [Hash] Returns the value in the form of hash
|
285
|
+
def _to_hash(value)
|
286
|
+
if value.is_a?(Array)
|
287
|
+
value.compact.map { |v| _to_hash(v) }
|
288
|
+
elsif value.is_a?(Hash)
|
289
|
+
{}.tap do |hash|
|
290
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
291
|
+
end
|
292
|
+
elsif value.respond_to? :to_hash
|
293
|
+
value.to_hash
|
294
|
+
else
|
295
|
+
value
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
end
|
300
|
+
|
301
|
+
end
|