Class: AdvancedBilling::SubscriptionCustomPrice
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::SubscriptionCustomPrice
- Defined in:
- lib/advanced_billing/models/subscription_custom_price.rb
Overview
(Optional) Used in place of ‘product_price_point_id` to define a custom price point unique to the subscription
Instance Attribute Summary collapse
-
#expiration_interval ⇒ Object
(Optional).
-
#expiration_interval_unit ⇒ ExpirationIntervalUnit
(Optional).
-
#handle ⇒ String
(Optional).
-
#initial_charge_after_trial ⇒ TrueClass | FalseClass
(Optional).
-
#initial_charge_in_cents ⇒ Object
(Optional).
-
#interval ⇒ Object
Required if using ‘custom_price` attribute.
-
#interval_unit ⇒ IntervalUnit
Required if using ‘custom_price` attribute.
-
#name ⇒ String
(Optional).
-
#price_in_cents ⇒ Object
Required if using ‘custom_price` attribute.
-
#tax_included ⇒ TrueClass | FalseClass
(Optional).
-
#trial_interval ⇒ Object
(Optional).
-
#trial_interval_unit ⇒ IntervalUnit
(Optional).
-
#trial_price_in_cents ⇒ Object
(Optional).
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(price_in_cents:, interval:, interval_unit:, name: SKIP, handle: SKIP, trial_price_in_cents: SKIP, trial_interval: SKIP, trial_interval_unit: SKIP, initial_charge_in_cents: SKIP, initial_charge_after_trial: SKIP, expiration_interval: SKIP, expiration_interval_unit: SKIP, tax_included: SKIP, additional_properties: {}) ⇒ SubscriptionCustomPrice
constructor
A new instance of SubscriptionCustomPrice.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(price_in_cents:, interval:, interval_unit:, name: SKIP, handle: SKIP, trial_price_in_cents: SKIP, trial_interval: SKIP, trial_interval_unit: SKIP, initial_charge_in_cents: SKIP, initial_charge_after_trial: SKIP, expiration_interval: SKIP, expiration_interval_unit: SKIP, tax_included: SKIP, additional_properties: {}) ⇒ SubscriptionCustomPrice
Returns a new instance of SubscriptionCustomPrice.
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 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 108 def initialize(price_in_cents:, interval:, interval_unit:, name: SKIP, handle: SKIP, trial_price_in_cents: SKIP, trial_interval: SKIP, trial_interval_unit: SKIP, initial_charge_in_cents: SKIP, initial_charge_after_trial: SKIP, expiration_interval: SKIP, expiration_interval_unit: SKIP, tax_included: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @name = name unless name == SKIP @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 @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 @tax_included = tax_included unless tax_included == SKIP end |
Instance Attribute Details
#expiration_interval ⇒ Object
(Optional)
55 56 57 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 55 def expiration_interval @expiration_interval end |
#expiration_interval_unit ⇒ ExpirationIntervalUnit
(Optional)
59 60 61 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 59 def expiration_interval_unit @expiration_interval_unit end |
#handle ⇒ String
(Optional)
19 20 21 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 19 def handle @handle end |
#initial_charge_after_trial ⇒ TrueClass | FalseClass
(Optional)
51 52 53 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 51 def initial_charge_after_trial @initial_charge_after_trial end |
#initial_charge_in_cents ⇒ Object
(Optional)
47 48 49 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 47 def initial_charge_in_cents @initial_charge_in_cents end |
#interval ⇒ Object
Required if using ‘custom_price` attribute.
27 28 29 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 27 def interval @interval end |
#interval_unit ⇒ IntervalUnit
Required if using ‘custom_price` attribute.
31 32 33 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 31 def interval_unit @interval_unit end |
#name ⇒ String
(Optional)
15 16 17 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 15 def name @name end |
#price_in_cents ⇒ Object
Required if using ‘custom_price` attribute.
23 24 25 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 23 def price_in_cents @price_in_cents end |
#tax_included ⇒ TrueClass | FalseClass
(Optional)
63 64 65 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 63 def tax_included @tax_included end |
#trial_interval ⇒ Object
(Optional)
39 40 41 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 39 def trial_interval @trial_interval end |
#trial_interval_unit ⇒ IntervalUnit
(Optional)
43 44 45 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 43 def trial_interval_unit @trial_interval_unit end |
#trial_price_in_cents ⇒ Object
(Optional)
35 36 37 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 35 def trial_price_in_cents @trial_price_in_cents end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
139 140 141 142 143 144 145 146 147 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 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 139 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. price_in_cents = hash.key?('price_in_cents') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:SubscriptionCustomPricePriceInCents), hash['price_in_cents'] ) : nil interval = hash.key?('interval') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:SubscriptionCustomPriceInterval), hash['interval'] ) : nil interval_unit = hash.key?('interval_unit') ? hash['interval_unit'] : nil name = hash.key?('name') ? hash['name'] : SKIP handle = hash.key?('handle') ? hash['handle'] : SKIP trial_price_in_cents = hash.key?('trial_price_in_cents') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:SubscriptionCustomPriceTrialPriceInCents), hash['trial_price_in_cents'] ) : SKIP trial_interval = hash.key?('trial_interval') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:SubscriptionCustomPriceTrialInterval), hash['trial_interval'] ) : SKIP trial_interval_unit = hash.key?('trial_interval_unit') ? hash['trial_interval_unit'] : SKIP initial_charge_in_cents = hash.key?('initial_charge_in_cents') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:SubscriptionCustomPriceInitialChargeInCents), 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') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:SubscriptionCustomPriceExpirationInterval), hash['expiration_interval'] ) : SKIP expiration_interval_unit = hash.key?('expiration_interval_unit') ? hash['expiration_interval_unit'] : SKIP tax_included = hash.key?('tax_included') ? hash['tax_included'] : SKIP # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. SubscriptionCustomPrice.new(price_in_cents: price_in_cents, interval: interval, interval_unit: interval_unit, name: name, handle: handle, trial_price_in_cents: trial_price_in_cents, trial_interval: trial_interval, trial_interval_unit: trial_interval_unit, 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, tax_included: tax_included, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 66 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['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['tax_included'] = 'tax_included' @_hash end |
.nullables ⇒ Object
An array for nullable fields
101 102 103 104 105 106 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 101 def self.nullables %w[ interval_unit expiration_interval_unit ] end |
.optionals ⇒ Object
An array for optional fields
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 85 def self.optionals %w[ name handle trial_price_in_cents trial_interval trial_interval_unit initial_charge_in_cents initial_charge_after_trial expiration_interval expiration_interval_unit tax_included ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/advanced_billing/models/subscription_custom_price.rb', line 194 def self.validate(value) if value.instance_of? self return ( UnionTypeLookUp.get(:SubscriptionCustomPricePriceInCents) .validate(value.price_in_cents) and UnionTypeLookUp.get(:SubscriptionCustomPriceInterval) .validate(value.interval) and APIHelper.valid_type?(value.interval_unit, ->(val) { IntervalUnit.validate(val) }) ) end return false unless value.instance_of? Hash ( UnionTypeLookUp.get(:SubscriptionCustomPricePriceInCents) .validate(value['price_in_cents']) and UnionTypeLookUp.get(:SubscriptionCustomPriceInterval) .validate(value['interval']) and APIHelper.valid_type?(value['interval_unit'], ->(val) { IntervalUnit.validate(val) }) ) end |