Class: AdvancedBilling::CreateComponentPricePoint
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::CreateComponentPricePoint
- Defined in:
- lib/advanced_billing/models/create_component_price_point.rb
Overview
CreateComponentPricePoint Model.
Instance Attribute Summary collapse
-
#handle ⇒ String
TODO: Write general description for this method.
-
#interval ⇒ Integer
The numerical interval.
-
#interval_unit ⇒ IntervalUnit
A string representing the interval unit for this price point, either month or day.
-
#name ⇒ String
TODO: Write general description for this method.
-
#prices ⇒ Array[Price]
The identifier for the pricing scheme.
-
#pricing_scheme ⇒ PricingScheme
The identifier for the pricing scheme.
-
#tax_included ⇒ TrueClass | FalseClass
Whether or not the price point includes tax.
-
#use_site_exchange_rate ⇒ TrueClass | FalseClass
Whether to use the site level exchange rate or define your own prices for each currency if you have multiple currencies defined on the site.
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(name:, pricing_scheme:, prices:, handle: SKIP, use_site_exchange_rate: true, tax_included: SKIP, interval: SKIP, interval_unit: SKIP, additional_properties: {}) ⇒ CreateComponentPricePoint
constructor
A new instance of CreateComponentPricePoint.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(name:, pricing_scheme:, prices:, handle: SKIP, use_site_exchange_rate: true, tax_included: SKIP, interval: SKIP, interval_unit: SKIP, additional_properties: {}) ⇒ CreateComponentPricePoint
Returns a new instance of CreateComponentPricePoint.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/advanced_billing/models/create_component_price_point.rb', line 88 def initialize(name:, pricing_scheme:, prices:, handle: SKIP, use_site_exchange_rate: true, tax_included: SKIP, interval: SKIP, interval_unit: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @name = name @handle = handle unless handle == SKIP @pricing_scheme = pricing_scheme @prices = prices @use_site_exchange_rate = use_site_exchange_rate unless use_site_exchange_rate == SKIP @tax_included = tax_included unless tax_included == SKIP @interval = interval unless interval == SKIP @interval_unit = interval_unit unless interval_unit == SKIP end |
Instance Attribute Details
#handle ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/create_component_price_point.rb', line 18 def handle @handle end |
#interval ⇒ Integer
The numerical interval. i.e. an interval of ‘30’ coupled with an interval_unit of day would mean this price point would renew every 30 days. This property is only available for sites with Multifrequency enabled.
48 49 50 |
# File 'lib/advanced_billing/models/create_component_price_point.rb', line 48 def interval @interval end |
#interval_unit ⇒ IntervalUnit
A string representing the interval unit for this price point, either month or day. This property is only available for sites with Multifrequency enabled.
54 55 56 |
# File 'lib/advanced_billing/models/create_component_price_point.rb', line 54 def interval_unit @interval_unit end |
#name ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/create_component_price_point.rb', line 14 def name @name end |
#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.
30 31 32 |
# File 'lib/advanced_billing/models/create_component_price_point.rb', line 30 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.
24 25 26 |
# File 'lib/advanced_billing/models/create_component_price_point.rb', line 24 def pricing_scheme @pricing_scheme end |
#tax_included ⇒ TrueClass | FalseClass
Whether or not the price point includes tax. Setting not supported when creating price points in bulk.
41 42 43 |
# File 'lib/advanced_billing/models/create_component_price_point.rb', line 41 def tax_included @tax_included end |
#use_site_exchange_rate ⇒ TrueClass | FalseClass
Whether to use the site level exchange rate or define your own prices for each currency if you have multiple currencies defined on the site. Setting not supported when creating price points in bulk.
36 37 38 |
# File 'lib/advanced_billing/models/create_component_price_point.rb', line 36 def use_site_exchange_rate @use_site_exchange_rate end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/advanced_billing/models/create_component_price_point.rb', line 108 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : nil pricing_scheme = hash.key?('pricing_scheme') ? 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 = nil unless hash.key?('prices') handle = hash.key?('handle') ? hash['handle'] : SKIP use_site_exchange_rate = hash['use_site_exchange_rate'] ||= true tax_included = hash.key?('tax_included') ? hash['tax_included'] : SKIP interval = hash.key?('interval') ? hash['interval'] : SKIP interval_unit = hash.key?('interval_unit') ? hash['interval_unit'] : SKIP # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. CreateComponentPricePoint.new(name: name, pricing_scheme: pricing_scheme, prices: prices, handle: handle, use_site_exchange_rate: use_site_exchange_rate, tax_included: tax_included, interval: interval, interval_unit: interval_unit, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/advanced_billing/models/create_component_price_point.rb', line 57 def self.names @_hash = {} if @_hash.nil? @_hash['name'] = 'name' @_hash['handle'] = 'handle' @_hash['pricing_scheme'] = 'pricing_scheme' @_hash['prices'] = 'prices' @_hash['use_site_exchange_rate'] = 'use_site_exchange_rate' @_hash['tax_included'] = 'tax_included' @_hash['interval'] = 'interval' @_hash['interval_unit'] = 'interval_unit' @_hash end |
.nullables ⇒ Object
An array for nullable fields
82 83 84 85 86 |
# File 'lib/advanced_billing/models/create_component_price_point.rb', line 82 def self.nullables %w[ interval_unit ] end |
.optionals ⇒ Object
An array for optional fields
71 72 73 74 75 76 77 78 79 |
# File 'lib/advanced_billing/models/create_component_price_point.rb', line 71 def self.optionals %w[ handle use_site_exchange_rate tax_included interval interval_unit ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/advanced_billing/models/create_component_price_point.rb', line 148 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.name, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.pricing_scheme, ->(val) { PricingScheme.validate(val) }) and APIHelper.valid_type?(value.prices, ->(val) { Price.validate(val) }, is_model_hash: true, is_inner_model_hash: true) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['name'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['pricing_scheme'], ->(val) { PricingScheme.validate(val) }) and APIHelper.valid_type?(value['prices'], ->(val) { Price.validate(val) }, is_model_hash: true, is_inner_model_hash: true) ) end |