Class: AdvancedBilling::ProductPricePoint
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::ProductPricePoint
- Defined in:
- lib/advanced_billing/models/product_price_point.rb
Overview
ProductPricePoint Model.
Instance Attribute Summary collapse
-
#archived_at ⇒ DateTime
Timestamp indicating when this price point was archived.
-
#created_at ⇒ DateTime
Timestamp indicating when this price point was created.
-
#currency_prices ⇒ Array[CurrencyPrice]
An array of currency pricing data is available when multiple currencies are defined for the site.
-
#expiration_interval ⇒ Integer
The numerical expiration interval.
-
#expiration_interval_unit ⇒ ExpirationIntervalUnit
A string representing the expiration interval unit for this product price point, either month, day or never.
-
#handle ⇒ String
The product price point API handle.
-
#id ⇒ Integer
TODO: Write general description for this method.
-
#initial_charge_after_trial ⇒ TrueClass | FalseClass
The product price point initial charge, in integer cents.
-
#initial_charge_in_cents ⇒ Integer
The product price point initial charge, in integer cents.
-
#interval ⇒ Integer
The numerical interval.
-
#interval_unit ⇒ IntervalUnit
A string representing the interval unit for this product price point, either month or day.
-
#introductory_offer ⇒ TrueClass | FalseClass
reserved for future use.
-
#name ⇒ String
The product price point name.
-
#price_in_cents ⇒ Integer
The product price point price, in integer cents.
-
#product_id ⇒ Integer
The product id this price point belongs to.
-
#subscription_id ⇒ Integer
The subscription id this price point belongs to.
-
#tax_included ⇒ TrueClass | FalseClass
Whether or not the price point includes tax.
-
#trial_interval ⇒ Integer
The numerical trial interval.
-
#trial_interval_unit ⇒ IntervalUnit
A string representing the trial interval unit for this product price point, either month or day.
-
#trial_price_in_cents ⇒ Integer
The product price point trial price, in integer cents.
-
#trial_type ⇒ String
A string representing the trial interval unit for this product price point, either month or day.
-
#type ⇒ PricePointType
The type of price point.
-
#updated_at ⇒ DateTime
Timestamp indicating when this price point was last updated.
-
#use_site_exchange_rate ⇒ TrueClass | FalseClass
Whether or not to use the site’s exchange rate or define your own pricing when your site has multiple currencies defined.
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.
Instance Method Summary collapse
-
#initialize(id: SKIP, name: SKIP, handle: SKIP, price_in_cents: SKIP, interval: SKIP, interval_unit: SKIP, trial_price_in_cents: SKIP, trial_interval: SKIP, trial_interval_unit: SKIP, trial_type: SKIP, introductory_offer: SKIP, initial_charge_in_cents: SKIP, initial_charge_after_trial: SKIP, expiration_interval: SKIP, expiration_interval_unit: SKIP, product_id: SKIP, archived_at: SKIP, created_at: SKIP, updated_at: SKIP, use_site_exchange_rate: SKIP, type: SKIP, tax_included: SKIP, subscription_id: SKIP, currency_prices: SKIP, additional_properties: {}) ⇒ ProductPricePoint
constructor
A new instance of ProductPricePoint.
- #to_custom_archived_at ⇒ Object
- #to_custom_created_at ⇒ Object
- #to_custom_updated_at ⇒ Object
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(id: SKIP, name: SKIP, handle: SKIP, price_in_cents: SKIP, interval: SKIP, interval_unit: SKIP, trial_price_in_cents: SKIP, trial_interval: SKIP, trial_interval_unit: SKIP, trial_type: SKIP, introductory_offer: SKIP, initial_charge_in_cents: SKIP, initial_charge_after_trial: SKIP, expiration_interval: SKIP, expiration_interval_unit: SKIP, product_id: SKIP, archived_at: SKIP, created_at: SKIP, updated_at: SKIP, use_site_exchange_rate: SKIP, type: SKIP, tax_included: SKIP, subscription_id: SKIP, currency_prices: SKIP, additional_properties: {}) ⇒ ProductPricePoint
Returns a new instance of ProductPricePoint.
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 201 def initialize(id: SKIP, name: SKIP, handle: SKIP, price_in_cents: SKIP, interval: SKIP, interval_unit: SKIP, trial_price_in_cents: SKIP, trial_interval: SKIP, trial_interval_unit: SKIP, trial_type: SKIP, introductory_offer: SKIP, initial_charge_in_cents: SKIP, initial_charge_after_trial: SKIP, expiration_interval: SKIP, expiration_interval_unit: SKIP, product_id: SKIP, archived_at: SKIP, created_at: SKIP, updated_at: SKIP, use_site_exchange_rate: SKIP, type: SKIP, tax_included: SKIP, subscription_id: SKIP, currency_prices: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @id = id unless id == SKIP @name = name unless name == SKIP @handle = handle unless handle == SKIP @price_in_cents = price_in_cents unless price_in_cents == SKIP @interval = interval unless interval == SKIP @interval_unit = interval_unit unless interval_unit == SKIP @trial_price_in_cents = trial_price_in_cents unless trial_price_in_cents == SKIP @trial_interval = trial_interval unless trial_interval == SKIP @trial_interval_unit = trial_interval_unit unless trial_interval_unit == SKIP @trial_type = trial_type unless trial_type == SKIP @introductory_offer = introductory_offer unless introductory_offer == SKIP @initial_charge_in_cents = initial_charge_in_cents unless initial_charge_in_cents == SKIP unless initial_charge_after_trial == SKIP @initial_charge_after_trial = initial_charge_after_trial end @expiration_interval = expiration_interval unless expiration_interval == SKIP @expiration_interval_unit = expiration_interval_unit unless expiration_interval_unit == SKIP @product_id = product_id unless product_id == SKIP @archived_at = archived_at unless archived_at == SKIP @created_at = created_at unless created_at == SKIP @updated_at = updated_at unless updated_at == SKIP @use_site_exchange_rate = use_site_exchange_rate unless use_site_exchange_rate == SKIP @type = type unless type == SKIP @tax_included = tax_included unless tax_included == SKIP @subscription_id = subscription_id unless subscription_id == SKIP @currency_prices = currency_prices unless currency_prices == SKIP end |
Instance Attribute Details
#archived_at ⇒ DateTime
Timestamp indicating when this price point was archived
89 90 91 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 89 def archived_at @archived_at end |
#created_at ⇒ DateTime
Timestamp indicating when this price point was created
93 94 95 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 93 def created_at @created_at end |
#currency_prices ⇒ Array[CurrencyPrice]
An array of currency pricing data is available when multiple currencies are defined for the site. It varies based on the use_site_exchange_rate setting for the price point. This parameter is present only in the response of read endpoints, after including the appropriate query parameter.
122 123 124 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 122 def currency_prices @currency_prices end |
#expiration_interval ⇒ Integer
The numerical expiration interval. i.e. an expiration_interval of ‘30’ coupled with an expiration_interval_unit of day would mean this product price point would expire after 30 days
76 77 78 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 76 def expiration_interval @expiration_interval end |
#expiration_interval_unit ⇒ ExpirationIntervalUnit
A string representing the expiration interval unit for this product price point, either month, day or never
81 82 83 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 81 def expiration_interval_unit @expiration_interval_unit end |
#handle ⇒ String
The product price point API handle
23 24 25 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 23 def handle @handle end |
#id ⇒ Integer
TODO: Write general description for this method
15 16 17 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 15 def id @id end |
#initial_charge_after_trial ⇒ TrueClass | FalseClass
The product price point initial charge, in integer cents
70 71 72 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 70 def initial_charge_after_trial @initial_charge_after_trial end |
#initial_charge_in_cents ⇒ Integer
The product price point initial charge, in integer cents
66 67 68 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 66 def initial_charge_in_cents @initial_charge_in_cents end |
#interval ⇒ Integer
The numerical interval. i.e. an interval of ‘30’ coupled with an interval_unit of day would mean this product price point would renew every 30 days
33 34 35 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 33 def interval @interval end |
#interval_unit ⇒ IntervalUnit
A string representing the interval unit for this product price point, either month or day
38 39 40 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 38 def interval_unit @interval_unit end |
#introductory_offer ⇒ TrueClass | FalseClass
reserved for future use
62 63 64 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 62 def introductory_offer @introductory_offer end |
#name ⇒ String
The product price point name
19 20 21 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 19 def name @name end |
#price_in_cents ⇒ Integer
The product price point price, in integer cents
27 28 29 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 27 def price_in_cents @price_in_cents end |
#product_id ⇒ Integer
The product id this price point belongs to
85 86 87 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 85 def product_id @product_id end |
#subscription_id ⇒ Integer
The subscription id this price point belongs to
114 115 116 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 114 def subscription_id @subscription_id end |
#tax_included ⇒ TrueClass | FalseClass
Whether or not the price point includes tax
110 111 112 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 110 def tax_included @tax_included end |
#trial_interval ⇒ Integer
The numerical trial interval. i.e. an interval of ‘30’ coupled with a trial_interval_unit of day would mean this product price point trial would last 30 days
48 49 50 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 48 def trial_interval @trial_interval end |
#trial_interval_unit ⇒ IntervalUnit
A string representing the trial interval unit for this product price point, either month or day
53 54 55 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 53 def trial_interval_unit @trial_interval_unit end |
#trial_price_in_cents ⇒ Integer
The product price point trial price, in integer cents
42 43 44 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 42 def trial_price_in_cents @trial_price_in_cents end |
#trial_type ⇒ String
A string representing the trial interval unit for this product price point, either month or day
58 59 60 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 58 def trial_type @trial_type end |
#type ⇒ PricePointType
The type of price point
106 107 108 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 106 def type @type end |
#updated_at ⇒ DateTime
Timestamp indicating when this price point was last updated
97 98 99 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 97 def updated_at @updated_at end |
#use_site_exchange_rate ⇒ TrueClass | FalseClass
Whether or not to use the site’s exchange rate or define your own pricing when your site has multiple currencies defined.
102 103 104 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 102 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.
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 247 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : SKIP name = hash.key?('name') ? hash['name'] : SKIP handle = hash.key?('handle') ? hash['handle'] : SKIP price_in_cents = hash.key?('price_in_cents') ? hash['price_in_cents'] : SKIP interval = hash.key?('interval') ? hash['interval'] : SKIP interval_unit = hash.key?('interval_unit') ? hash['interval_unit'] : SKIP trial_price_in_cents = hash.key?('trial_price_in_cents') ? hash['trial_price_in_cents'] : SKIP trial_interval = hash.key?('trial_interval') ? hash['trial_interval'] : SKIP trial_interval_unit = hash.key?('trial_interval_unit') ? hash['trial_interval_unit'] : SKIP trial_type = hash.key?('trial_type') ? hash['trial_type'] : SKIP introductory_offer = hash.key?('introductory_offer') ? hash['introductory_offer'] : SKIP initial_charge_in_cents = hash.key?('initial_charge_in_cents') ? hash['initial_charge_in_cents'] : SKIP initial_charge_after_trial = hash.key?('initial_charge_after_trial') ? hash['initial_charge_after_trial'] : SKIP expiration_interval = hash.key?('expiration_interval') ? hash['expiration_interval'] : SKIP expiration_interval_unit = hash.key?('expiration_interval_unit') ? hash['expiration_interval_unit'] : SKIP product_id = hash.key?('product_id') ? hash['product_id'] : SKIP archived_at = if hash.key?('archived_at') (DateTimeHelper.from_rfc3339(hash['archived_at']) if hash['archived_at']) else SKIP end created_at = if hash.key?('created_at') (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at']) else SKIP end updated_at = if hash.key?('updated_at') (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at']) else SKIP end use_site_exchange_rate = hash.key?('use_site_exchange_rate') ? hash['use_site_exchange_rate'] : SKIP type = hash.key?('type') ? hash['type'] : SKIP tax_included = hash.key?('tax_included') ? hash['tax_included'] : SKIP subscription_id = hash.key?('subscription_id') ? hash['subscription_id'] : SKIP # Parameter is an array, so we need to iterate through it currency_prices = nil unless hash['currency_prices'].nil? currency_prices = [] hash['currency_prices'].each do |structure| currency_prices << (CurrencyPrice.from_hash(structure) if structure) end end currency_prices = SKIP unless hash.key?('currency_prices') # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. ProductPricePoint.new(id: id, name: name, handle: handle, price_in_cents: price_in_cents, interval: interval, interval_unit: interval_unit, trial_price_in_cents: trial_price_in_cents, trial_interval: trial_interval, trial_interval_unit: trial_interval_unit, trial_type: trial_type, introductory_offer: introductory_offer, initial_charge_in_cents: initial_charge_in_cents, initial_charge_after_trial: initial_charge_after_trial, expiration_interval: expiration_interval, expiration_interval_unit: expiration_interval_unit, product_id: product_id, archived_at: archived_at, created_at: created_at, updated_at: updated_at, use_site_exchange_rate: use_site_exchange_rate, type: type, tax_included: tax_included, subscription_id: subscription_id, currency_prices: currency_prices, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
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 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 125 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['name'] = 'name' @_hash['handle'] = 'handle' @_hash['price_in_cents'] = 'price_in_cents' @_hash['interval'] = 'interval' @_hash['interval_unit'] = 'interval_unit' @_hash['trial_price_in_cents'] = 'trial_price_in_cents' @_hash['trial_interval'] = 'trial_interval' @_hash['trial_interval_unit'] = 'trial_interval_unit' @_hash['trial_type'] = 'trial_type' @_hash['introductory_offer'] = 'introductory_offer' @_hash['initial_charge_in_cents'] = 'initial_charge_in_cents' @_hash['initial_charge_after_trial'] = 'initial_charge_after_trial' @_hash['expiration_interval'] = 'expiration_interval' @_hash['expiration_interval_unit'] = 'expiration_interval_unit' @_hash['product_id'] = 'product_id' @_hash['archived_at'] = 'archived_at' @_hash['created_at'] = 'created_at' @_hash['updated_at'] = 'updated_at' @_hash['use_site_exchange_rate'] = 'use_site_exchange_rate' @_hash['type'] = 'type' @_hash['tax_included'] = 'tax_included' @_hash['subscription_id'] = 'subscription_id' @_hash['currency_prices'] = 'currency_prices' @_hash end |
.nullables ⇒ Object
An array for nullable fields
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 185 def self.nullables %w[ handle trial_price_in_cents trial_interval trial_interval_unit introductory_offer initial_charge_in_cents initial_charge_after_trial expiration_interval expiration_interval_unit archived_at subscription_id ] end |
.optionals ⇒ Object
An array for optional fields
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 155 def self.optionals %w[ id name handle price_in_cents interval interval_unit trial_price_in_cents trial_interval trial_interval_unit trial_type introductory_offer initial_charge_in_cents initial_charge_after_trial expiration_interval expiration_interval_unit product_id archived_at created_at updated_at use_site_exchange_rate type tax_included subscription_id currency_prices ] end |
Instance Method Details
#to_custom_archived_at ⇒ Object
339 340 341 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 339 def to_custom_archived_at DateTimeHelper.to_rfc3339(archived_at) end |
#to_custom_created_at ⇒ Object
343 344 345 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 343 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_updated_at ⇒ Object
347 348 349 |
# File 'lib/advanced_billing/models/product_price_point.rb', line 347 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |