Class: AdvancedBilling::OveragePricing
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::OveragePricing
- Defined in:
- lib/advanced_billing/models/overage_pricing.rb
Overview
OveragePricing Model.
Instance Attribute Summary collapse
-
#prices ⇒ Array[Price]
The identifier for the pricing scheme.
-
#pricing_scheme ⇒ PricingScheme
The identifier for the pricing scheme.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(pricing_scheme = nil, prices = SKIP) ⇒ OveragePricing
constructor
A new instance of OveragePricing.
Methods inherited from BaseModel
Constructor Details
#initialize(pricing_scheme = nil, prices = SKIP) ⇒ OveragePricing
Returns a new instance of OveragePricing.
44 45 46 47 |
# File 'lib/advanced_billing/models/overage_pricing.rb', line 44 def initialize(pricing_scheme = nil, prices = SKIP) @pricing_scheme = pricing_scheme @prices = prices unless prices == SKIP end |
Instance Attribute Details
#prices ⇒ Array[Price]
The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.
22 23 24 |
# File 'lib/advanced_billing/models/overage_pricing.rb', line 22 def prices @prices end |
#pricing_scheme ⇒ PricingScheme
The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.
16 17 18 |
# File 'lib/advanced_billing/models/overage_pricing.rb', line 16 def pricing_scheme @pricing_scheme end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/advanced_billing/models/overage_pricing.rb', line 50 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. pricing_scheme = hash.key?('pricing_scheme') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:OveragePricingPricingScheme), hash['pricing_scheme'] ) : nil # Parameter is an array, so we need to iterate through it prices = nil unless hash['prices'].nil? prices = [] hash['prices'].each do |structure| prices << (Price.from_hash(structure) if structure) end end prices = SKIP unless hash.key?('prices') # Create object from extracted values. OveragePricing.new(pricing_scheme, prices) end |
.names ⇒ Object
A mapping from model property names to API property names.
25 26 27 28 29 30 |
# File 'lib/advanced_billing/models/overage_pricing.rb', line 25 def self.names @_hash = {} if @_hash.nil? @_hash['pricing_scheme'] = 'pricing_scheme' @_hash['prices'] = 'prices' @_hash end |
.nullables ⇒ Object
An array for nullable fields
40 41 42 |
# File 'lib/advanced_billing/models/overage_pricing.rb', line 40 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
33 34 35 36 37 |
# File 'lib/advanced_billing/models/overage_pricing.rb', line 33 def self.optionals %w[ prices ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/advanced_billing/models/overage_pricing.rb', line 75 def self.validate(value) if value.instance_of? self return UnionTypeLookUp.get(:OveragePricingPricingScheme) .validate(value.pricing_scheme) end return false unless value.instance_of? Hash UnionTypeLookUp.get(:OveragePricingPricingScheme) .validate(value['pricing_scheme']) end |