Class: AdvancedBilling::CreatePrepaidUsageComponentPricePoint
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::CreatePrepaidUsageComponentPricePoint
- Defined in:
- lib/advanced_billing/models/create_prepaid_usage_component_price_point.rb
Overview
CreatePrepaidUsageComponentPricePoint 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
TODO: Write general description for this method.
-
#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 = nil, pricing_scheme = nil, prices = nil, overage_pricing = nil, handle = SKIP, use_site_exchange_rate = true, rollover_prepaid_remainder = SKIP, renew_prepaid_allocation = SKIP, expiration_interval = SKIP, expiration_interval_unit = SKIP) ⇒ CreatePrepaidUsageComponentPricePoint
constructor
A new instance of CreatePrepaidUsageComponentPricePoint.
Methods inherited from BaseModel
Constructor Details
#initialize(name = nil, pricing_scheme = nil, prices = nil, overage_pricing = nil, handle = SKIP, use_site_exchange_rate = true, rollover_prepaid_remainder = SKIP, renew_prepaid_allocation = SKIP, expiration_interval = SKIP, expiration_interval_unit = SKIP) ⇒ CreatePrepaidUsageComponentPricePoint
Returns a new instance of CreatePrepaidUsageComponentPricePoint.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/advanced_billing/models/create_prepaid_usage_component_price_point.rb', line 92 def initialize(name = nil, pricing_scheme = nil, prices = nil, overage_pricing = nil, handle = SKIP, use_site_exchange_rate = true, rollover_prepaid_remainder = SKIP, renew_prepaid_allocation = SKIP, expiration_interval = SKIP, expiration_interval_unit = SKIP) @name = name @handle = handle unless handle == SKIP @pricing_scheme = pricing_scheme @prices = prices @overage_pricing = overage_pricing @use_site_exchange_rate = use_site_exchange_rate unless use_site_exchange_rate == 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
51 52 53 |
# File 'lib/advanced_billing/models/create_prepaid_usage_component_price_point.rb', line 51 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
57 58 59 |
# File 'lib/advanced_billing/models/create_prepaid_usage_component_price_point.rb', line 57 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/create_prepaid_usage_component_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/create_prepaid_usage_component_price_point.rb', line 14 def name @name end |
#overage_pricing ⇒ OveragePricing
TODO: Write general description for this method
30 31 32 |
# File 'lib/advanced_billing/models/create_prepaid_usage_component_price_point.rb', line 30 def overage_pricing @overage_pricing end |
#prices ⇒ Array[Price]
TODO: Write general description for this method
26 27 28 |
# File 'lib/advanced_billing/models/create_prepaid_usage_component_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/create_prepaid_usage_component_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
45 46 47 |
# File 'lib/advanced_billing/models/create_prepaid_usage_component_price_point.rb', line 45 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
40 41 42 |
# File 'lib/advanced_billing/models/create_prepaid_usage_component_price_point.rb', line 40 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.
35 36 37 |
# File 'lib/advanced_billing/models/create_prepaid_usage_component_price_point.rb', line 35 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.
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 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/advanced_billing/models/create_prepaid_usage_component_price_point.rb', line 114 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') overage_pricing = OveragePricing.from_hash(hash['overage_pricing']) if hash['overage_pricing'] handle = hash.key?('handle') ? hash['handle'] : SKIP use_site_exchange_rate = hash['use_site_exchange_rate'] ||= true 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(:CreatePrepaidUsageComponentPricePointExpirationIntervalUnit), hash['expiration_interval_unit'] ) : SKIP # Create object from extracted values. CreatePrepaidUsageComponentPricePoint.new(name, pricing_scheme, prices, overage_pricing, handle, use_site_exchange_rate, rollover_prepaid_remainder, renew_prepaid_allocation, expiration_interval, expiration_interval_unit) end |
.names ⇒ Object
A mapping from model property names to API property names.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/advanced_billing/models/create_prepaid_usage_component_price_point.rb', line 60 def self.names @_hash = {} if @_hash.nil? @_hash['name'] = 'name' @_hash['handle'] = 'handle' @_hash['pricing_scheme'] = 'pricing_scheme' @_hash['prices'] = 'prices' @_hash['overage_pricing'] = 'overage_pricing' @_hash['use_site_exchange_rate'] = 'use_site_exchange_rate' @_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
88 89 90 |
# File 'lib/advanced_billing/models/create_prepaid_usage_component_price_point.rb', line 88 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/advanced_billing/models/create_prepaid_usage_component_price_point.rb', line 76 def self.optionals %w[ handle use_site_exchange_rate 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.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/advanced_billing/models/create_prepaid_usage_component_price_point.rb', line 160 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) { val.instance_of? String }) and APIHelper.valid_type?(value.prices, ->(val) { Price.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value.overage_pricing, ->(val) { OveragePricing.validate(val) }, is_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) { val.instance_of? String }) and APIHelper.valid_type?(value['prices'], ->(val) { Price.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value['overage_pricing'], ->(val) { OveragePricing.validate(val) }, is_model_hash: true) ) end |