Class: AdvancedBilling::PricePoint
- Defined in:
- lib/advanced_billing/models/price_point.rb
Overview
PricePoint Model.
Instance Attribute Summary collapse
-
#expiration_interval ⇒ Float
(only for prepaid usage components where rollover_prepaid_remainder is true) The number of ‘expiration_interval_unit`s after which rollover amounts should expire.
-
#expiration_interval_unit ⇒ IntervalUnit
(only for prepaid usage components where rollover_prepaid_remainder is true) The number of ‘expiration_interval_unit`s after which rollover amounts should expire.
-
#handle ⇒ String
TODO: Write general description for this method.
-
#name ⇒ String
TODO: Write general description for this method.
-
#overage_pricing ⇒ OveragePricing
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.
-
#prices ⇒ Array[Price]
TODO: Write general description for this method.
-
#pricing_scheme ⇒ String
TODO: Write general description for this method.
-
#renew_prepaid_allocation ⇒ TrueClass | FalseClass
Boolean which controls whether or not the allocated quantity should be renewed at the beginning of each period.
-
#rollover_prepaid_remainder ⇒ TrueClass | FalseClass
Boolean which controls whether or not remaining units should be rolled over to the next period.
-
#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 = SKIP, handle = SKIP, pricing_scheme = SKIP, prices = SKIP, use_site_exchange_rate = true, overage_pricing = SKIP, rollover_prepaid_remainder = SKIP, renew_prepaid_allocation = SKIP, expiration_interval = SKIP, expiration_interval_unit = SKIP) ⇒ PricePoint
constructor
A new instance of PricePoint.
Methods inherited from BaseModel
Constructor Details
#initialize(name = SKIP, handle = SKIP, pricing_scheme = SKIP, prices = SKIP, use_site_exchange_rate = true, overage_pricing = SKIP, rollover_prepaid_remainder = SKIP, renew_prepaid_allocation = SKIP, expiration_interval = SKIP, expiration_interval_unit = SKIP) ⇒ PricePoint
Returns a new instance of PricePoint.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/advanced_billing/models/price_point.rb', line 97 def initialize(name = SKIP, handle = SKIP, pricing_scheme = SKIP, prices = SKIP, use_site_exchange_rate = true, overage_pricing = SKIP, rollover_prepaid_remainder = SKIP, renew_prepaid_allocation = SKIP, expiration_interval = SKIP, expiration_interval_unit = SKIP) @name = name unless name == SKIP @handle = handle unless handle == SKIP @pricing_scheme = pricing_scheme unless pricing_scheme == SKIP @prices = prices unless prices == SKIP @use_site_exchange_rate = use_site_exchange_rate unless use_site_exchange_rate == SKIP @overage_pricing = overage_pricing unless overage_pricing == SKIP unless rollover_prepaid_remainder == SKIP @rollover_prepaid_remainder = rollover_prepaid_remainder end @renew_prepaid_allocation = renew_prepaid_allocation unless renew_prepaid_allocation == SKIP @expiration_interval = expiration_interval unless expiration_interval == SKIP @expiration_interval_unit = expiration_interval_unit unless expiration_interval_unit == SKIP end |
Instance Attribute Details
#expiration_interval ⇒ Float
(only for prepaid usage components where rollover_prepaid_remainder is true) The number of ‘expiration_interval_unit`s after which rollover amounts should expire
52 53 54 |
# File 'lib/advanced_billing/models/price_point.rb', line 52 def expiration_interval @expiration_interval end |
#expiration_interval_unit ⇒ IntervalUnit
(only for prepaid usage components where rollover_prepaid_remainder is true) The number of ‘expiration_interval_unit`s after which rollover amounts should expire
58 59 60 |
# File 'lib/advanced_billing/models/price_point.rb', line 58 def expiration_interval_unit @expiration_interval_unit end |
#handle ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/price_point.rb', line 18 def handle @handle end |
#name ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/price_point.rb', line 14 def name @name end |
#overage_pricing ⇒ OveragePricing
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.
36 37 38 |
# File 'lib/advanced_billing/models/price_point.rb', line 36 def overage_pricing @overage_pricing end |
#prices ⇒ Array[Price]
TODO: Write general description for this method
26 27 28 |
# File 'lib/advanced_billing/models/price_point.rb', line 26 def prices @prices end |
#pricing_scheme ⇒ String
TODO: Write general description for this method
22 23 24 |
# File 'lib/advanced_billing/models/price_point.rb', line 22 def pricing_scheme @pricing_scheme end |
#renew_prepaid_allocation ⇒ TrueClass | FalseClass
Boolean which controls whether or not the allocated quantity should be renewed at the beginning of each period
46 47 48 |
# File 'lib/advanced_billing/models/price_point.rb', line 46 def renew_prepaid_allocation @renew_prepaid_allocation end |
#rollover_prepaid_remainder ⇒ TrueClass | FalseClass
Boolean which controls whether or not remaining units should be rolled over to the next period
41 42 43 |
# File 'lib/advanced_billing/models/price_point.rb', line 41 def rollover_prepaid_remainder @rollover_prepaid_remainder 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.
31 32 33 |
# File 'lib/advanced_billing/models/price_point.rb', line 31 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.
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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/advanced_billing/models/price_point.rb', line 118 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : SKIP handle = hash.key?('handle') ? hash['handle'] : SKIP pricing_scheme = hash.key?('pricing_scheme') ? hash['pricing_scheme'] : SKIP # 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') use_site_exchange_rate = hash['use_site_exchange_rate'] ||= true overage_pricing = OveragePricing.from_hash(hash['overage_pricing']) if hash['overage_pricing'] rollover_prepaid_remainder = hash.key?('rollover_prepaid_remainder') ? hash['rollover_prepaid_remainder'] : SKIP renew_prepaid_allocation = hash.key?('renew_prepaid_allocation') ? hash['renew_prepaid_allocation'] : SKIP expiration_interval = hash.key?('expiration_interval') ? hash['expiration_interval'] : SKIP expiration_interval_unit = hash.key?('expiration_interval_unit') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:PricePointExpirationIntervalUnit), hash['expiration_interval_unit'] ) : SKIP # Create object from extracted values. PricePoint.new(name, handle, pricing_scheme, prices, use_site_exchange_rate, overage_pricing, rollover_prepaid_remainder, renew_prepaid_allocation, expiration_interval, expiration_interval_unit) end |
.names ⇒ Object
A mapping from model property names to API property names.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/advanced_billing/models/price_point.rb', line 61 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['overage_pricing'] = 'overage_pricing' @_hash['rollover_prepaid_remainder'] = 'rollover_prepaid_remainder' @_hash['renew_prepaid_allocation'] = 'renew_prepaid_allocation' @_hash['expiration_interval'] = 'expiration_interval' @_hash['expiration_interval_unit'] = 'expiration_interval_unit' @_hash end |
.nullables ⇒ Object
An array for nullable fields
93 94 95 |
# File 'lib/advanced_billing/models/price_point.rb', line 93 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/advanced_billing/models/price_point.rb', line 77 def self.optionals %w[ name handle pricing_scheme prices use_site_exchange_rate overage_pricing rollover_prepaid_remainder renew_prepaid_allocation expiration_interval expiration_interval_unit ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
164 165 166 167 168 169 170 |
# File 'lib/advanced_billing/models/price_point.rb', line 164 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |