Class: AdvancedBilling::CreateProductPricePoint
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::CreateProductPricePoint
- Defined in:
- lib/advanced_billing/models/create_product_price_point.rb
Overview
CreateProductPricePoint Model.
Instance Attribute Summary collapse
-
#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.
-
#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.
-
#name ⇒ String
The product price point name.
-
#price_in_cents ⇒ Integer
The product price point price, in integer cents.
-
#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.
-
#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(name:, price_in_cents:, interval:, interval_unit:, handle: SKIP, trial_price_in_cents: SKIP, trial_interval: SKIP, trial_interval_unit: SKIP, trial_type: SKIP, initial_charge_in_cents: SKIP, initial_charge_after_trial: SKIP, expiration_interval: SKIP, expiration_interval_unit: SKIP, use_site_exchange_rate: true, additional_properties: {}) ⇒ CreateProductPricePoint
constructor
A new instance of CreateProductPricePoint.
Methods inherited from BaseModel
Constructor Details
#initialize(name:, price_in_cents:, interval:, interval_unit:, handle: SKIP, trial_price_in_cents: SKIP, trial_interval: SKIP, trial_interval_unit: SKIP, trial_type: SKIP, initial_charge_in_cents: SKIP, initial_charge_after_trial: SKIP, expiration_interval: SKIP, expiration_interval_unit: SKIP, use_site_exchange_rate: true, additional_properties: {}) ⇒ CreateProductPricePoint
Returns a new instance of CreateProductPricePoint.
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 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 122 def initialize(name:, price_in_cents:, interval:, interval_unit:, handle: SKIP, trial_price_in_cents: SKIP, trial_interval: SKIP, trial_interval_unit: SKIP, trial_type: SKIP, initial_charge_in_cents: SKIP, initial_charge_after_trial: SKIP, expiration_interval: SKIP, expiration_interval_unit: SKIP, use_site_exchange_rate: true, additional_properties: {}) @name = name @handle = handle unless handle == SKIP @price_in_cents = price_in_cents @interval = interval @interval_unit = interval_unit @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 @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 @use_site_exchange_rate = use_site_exchange_rate unless use_site_exchange_rate == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#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.
67 68 69 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 67 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
72 73 74 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 72 def expiration_interval_unit @expiration_interval_unit end |
#handle ⇒ String
The product price point API handle
18 19 20 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 18 def handle @handle end |
#initial_charge_after_trial ⇒ TrueClass | FalseClass
The product price point initial charge, in integer cents
61 62 63 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 61 def initial_charge_after_trial @initial_charge_after_trial end |
#initial_charge_in_cents ⇒ Integer
The product price point initial charge, in integer cents
57 58 59 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 57 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
28 29 30 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 28 def interval @interval end |
#interval_unit ⇒ IntervalUnit
A string representing the interval unit for this product price point, either month or day
33 34 35 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 33 def interval_unit @interval_unit end |
#name ⇒ String
The product price point name
14 15 16 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 14 def name @name end |
#price_in_cents ⇒ Integer
The product price point price, in integer cents
22 23 24 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 22 def price_in_cents @price_in_cents 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.
43 44 45 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 43 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
48 49 50 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 48 def trial_interval_unit @trial_interval_unit end |
#trial_price_in_cents ⇒ Integer
The product price point trial price, in integer cents
37 38 39 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 37 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
53 54 55 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 53 def trial_type @trial_type 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.
77 78 79 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 77 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.
154 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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 154 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : nil price_in_cents = hash.key?('price_in_cents') ? hash['price_in_cents'] : nil interval = hash.key?('interval') ? hash['interval'] : nil interval_unit = hash.key?('interval_unit') ? hash['interval_unit'] : nil handle = hash.key?('handle') ? hash['handle'] : 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 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 use_site_exchange_rate = hash['use_site_exchange_rate'] ||= true # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. CreateProductPricePoint.new(name: name, price_in_cents: price_in_cents, interval: interval, interval_unit: interval_unit, handle: handle, trial_price_in_cents: trial_price_in_cents, trial_interval: trial_interval, trial_interval_unit: trial_interval_unit, trial_type: trial_type, 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, use_site_exchange_rate: use_site_exchange_rate, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 80 def self.names @_hash = {} if @_hash.nil? @_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['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['use_site_exchange_rate'] = 'use_site_exchange_rate' @_hash end |
.nullables ⇒ Object
An array for nullable fields
116 117 118 119 120 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 116 def self.nullables %w[ expiration_interval_unit ] end |
.optionals ⇒ Object
An array for optional fields
100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/advanced_billing/models/create_product_price_point.rb', line 100 def self.optionals %w[ handle trial_price_in_cents trial_interval trial_interval_unit trial_type initial_charge_in_cents initial_charge_after_trial expiration_interval expiration_interval_unit use_site_exchange_rate ] end |