Class: AdvancedBilling::CreateOrUpdateProduct
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::CreateOrUpdateProduct
- Defined in:
- lib/advanced_billing/models/create_or_update_product.rb
Overview
CreateOrUpdateProduct Model.
Instance Attribute Summary collapse
-
#accounting_code ⇒ String
E.g.
-
#auto_create_signup_page ⇒ TrueClass | FalseClass
A string representing the expiration interval unit for this product, either month, day or never.
-
#description ⇒ String
The product description.
-
#expiration_interval ⇒ Integer
The numerical expiration interval.
-
#expiration_interval_unit ⇒ ExpirationIntervalUnit
A string representing the expiration interval unit for this product, either month, day or never.
-
#handle ⇒ String
The product API handle.
-
#interval ⇒ Integer
The numerical interval.
-
#interval_unit ⇒ IntervalUnit
A string representing the interval unit for this product, either month or day.
-
#name ⇒ String
The product name.
-
#price_in_cents ⇒ Integer
The product price, in integer cents.
-
#require_credit_card ⇒ TrueClass | FalseClass
Deprecated value that can be ignored unless you have legacy hosted pages.
-
#tax_code ⇒ String
A string representing the tax code related to the product type.
-
#trial_interval ⇒ Integer
The numerical trial interval.
-
#trial_interval_unit ⇒ IntervalUnit
A string representing the trial interval unit for this product, either month or day.
-
#trial_price_in_cents ⇒ Integer
The product trial price, in integer cents.
-
#trial_type ⇒ TrialType
Indicates how a trial is handled when the trail period ends and there is no credit card on file.
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:, description:, price_in_cents:, interval:, interval_unit:, handle: SKIP, accounting_code: SKIP, require_credit_card: SKIP, trial_price_in_cents: SKIP, trial_interval: SKIP, trial_interval_unit: SKIP, trial_type: SKIP, expiration_interval: SKIP, expiration_interval_unit: SKIP, auto_create_signup_page: SKIP, tax_code: SKIP, additional_properties: {}) ⇒ CreateOrUpdateProduct
constructor
A new instance of CreateOrUpdateProduct.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(name:, description:, price_in_cents:, interval:, interval_unit:, handle: SKIP, accounting_code: SKIP, require_credit_card: SKIP, trial_price_in_cents: SKIP, trial_interval: SKIP, trial_interval_unit: SKIP, trial_type: SKIP, expiration_interval: SKIP, expiration_interval_unit: SKIP, auto_create_signup_page: SKIP, tax_code: SKIP, additional_properties: {}) ⇒ CreateOrUpdateProduct
Returns a new instance of CreateOrUpdateProduct.
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 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 142 def initialize(name:, description:, price_in_cents:, interval:, interval_unit:, handle: SKIP, accounting_code: SKIP, require_credit_card: SKIP, trial_price_in_cents: SKIP, trial_interval: SKIP, trial_interval_unit: SKIP, trial_type: SKIP, expiration_interval: SKIP, expiration_interval_unit: SKIP, auto_create_signup_page: SKIP, tax_code: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @name = name @handle = handle unless handle == SKIP @description = description @accounting_code = accounting_code unless accounting_code == SKIP @require_credit_card = require_credit_card unless require_credit_card == 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 @expiration_interval = expiration_interval unless expiration_interval == SKIP @expiration_interval_unit = expiration_interval_unit unless expiration_interval_unit == SKIP @auto_create_signup_page = auto_create_signup_page unless auto_create_signup_page == SKIP @tax_code = tax_code unless tax_code == SKIP end |
Instance Attribute Details
#accounting_code ⇒ String
E.g. Internal ID or SKU Number
26 27 28 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 26 def accounting_code @accounting_code end |
#auto_create_signup_page ⇒ TrueClass | FalseClass
A string representing the expiration interval unit for this product, either month, day or never
86 87 88 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 86 def auto_create_signup_page @auto_create_signup_page end |
#description ⇒ String
The product description
22 23 24 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 22 def description @description 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 would expire after 30 days.
76 77 78 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 76 def expiration_interval @expiration_interval end |
#expiration_interval_unit ⇒ ExpirationIntervalUnit
A string representing the expiration interval unit for this product, either month, day or never
81 82 83 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 81 def expiration_interval_unit @expiration_interval_unit end |
#handle ⇒ String
The product API handle
18 19 20 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 18 def handle @handle end |
#interval ⇒ Integer
The numerical interval. i.e. an interval of ‘30’ coupled with an interval_unit of day would mean this product would renew every 30 days
41 42 43 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 41 def interval @interval end |
#interval_unit ⇒ IntervalUnit
A string representing the interval unit for this product, either month or day
46 47 48 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 46 def interval_unit @interval_unit end |
#name ⇒ String
The product name
14 15 16 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 14 def name @name end |
#price_in_cents ⇒ Integer
The product price, in integer cents
36 37 38 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 36 def price_in_cents @price_in_cents end |
#require_credit_card ⇒ TrueClass | FalseClass
Deprecated value that can be ignored unless you have legacy hosted pages. For Public Signup Page users, read this attribute from under the signup page.
32 33 34 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 32 def require_credit_card @require_credit_card end |
#tax_code ⇒ String
A string representing the tax code related to the product type. This is especially important when using AvaTax to tax based on locale. This attribute has a max length of 25 characters.
92 93 94 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 92 def tax_code @tax_code 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 trial would last 30 days.
56 57 58 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 56 def trial_interval @trial_interval end |
#trial_interval_unit ⇒ IntervalUnit
A string representing the trial interval unit for this product, either month or day
61 62 63 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 61 def trial_interval_unit @trial_interval_unit end |
#trial_price_in_cents ⇒ Integer
The product trial price, in integer cents
50 51 52 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 50 def trial_price_in_cents @trial_price_in_cents end |
#trial_type ⇒ TrialType
Indicates how a trial is handled when the trail period ends and there is no credit card on file. For ‘no_obligation`, the subscription transitions to a Trial Ended state. Maxio will not send any emails or statements. For `payment_expected`, the subscription transitions to a Past Due state. Maxio will send normal dunning emails and statements according to your other settings.
70 71 72 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 70 def trial_type @trial_type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 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 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 174 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : nil description = hash.key?('description') ? hash['description'] : 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 accounting_code = hash.key?('accounting_code') ? hash['accounting_code'] : SKIP require_credit_card = hash.key?('require_credit_card') ? hash['require_credit_card'] : 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 expiration_interval = hash.key?('expiration_interval') ? hash['expiration_interval'] : SKIP expiration_interval_unit = hash.key?('expiration_interval_unit') ? hash['expiration_interval_unit'] : SKIP auto_create_signup_page = hash.key?('auto_create_signup_page') ? hash['auto_create_signup_page'] : SKIP tax_code = hash.key?('tax_code') ? hash['tax_code'] : SKIP # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. CreateOrUpdateProduct.new(name: name, description: description, price_in_cents: price_in_cents, interval: interval, interval_unit: interval_unit, handle: handle, accounting_code: accounting_code, require_credit_card: require_credit_card, trial_price_in_cents: trial_price_in_cents, trial_interval: trial_interval, trial_interval_unit: trial_interval_unit, trial_type: trial_type, expiration_interval: expiration_interval, expiration_interval_unit: expiration_interval_unit, auto_create_signup_page: auto_create_signup_page, tax_code: tax_code, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 95 def self.names @_hash = {} if @_hash.nil? @_hash['name'] = 'name' @_hash['handle'] = 'handle' @_hash['description'] = 'description' @_hash['accounting_code'] = 'accounting_code' @_hash['require_credit_card'] = 'require_credit_card' @_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['expiration_interval'] = 'expiration_interval' @_hash['expiration_interval_unit'] = 'expiration_interval_unit' @_hash['auto_create_signup_page'] = 'auto_create_signup_page' @_hash['tax_code'] = 'tax_code' @_hash end |
.nullables ⇒ Object
An array for nullable fields
134 135 136 137 138 139 140 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 134 def self.nullables %w[ trial_interval_unit trial_type expiration_interval_unit ] end |
.optionals ⇒ Object
An array for optional fields
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 117 def self.optionals %w[ handle accounting_code require_credit_card trial_price_in_cents trial_interval trial_interval_unit trial_type expiration_interval expiration_interval_unit auto_create_signup_page tax_code ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 241 def inspect class_name = self.class.name.split('::').last "<#{class_name} name: #{@name.inspect}, handle: #{@handle.inspect}, description:"\ " #{@description.inspect}, accounting_code: #{@accounting_code.inspect},"\ " require_credit_card: #{@require_credit_card.inspect}, price_in_cents:"\ " #{@price_in_cents.inspect}, interval: #{@interval.inspect}, interval_unit:"\ " #{@interval_unit.inspect}, trial_price_in_cents: #{@trial_price_in_cents.inspect},"\ " trial_interval: #{@trial_interval.inspect}, trial_interval_unit:"\ " #{@trial_interval_unit.inspect}, trial_type: #{@trial_type.inspect}, expiration_interval:"\ " #{@expiration_interval.inspect}, expiration_interval_unit:"\ " #{@expiration_interval_unit.inspect}, auto_create_signup_page:"\ " #{@auto_create_signup_page.inspect}, tax_code: #{@tax_code.inspect},"\ " additional_properties: #{get_additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 228 def to_s class_name = self.class.name.split('::').last "<#{class_name} name: #{@name}, handle: #{@handle}, description: #{@description},"\ " accounting_code: #{@accounting_code}, require_credit_card: #{@require_credit_card},"\ " 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}, expiration_interval: #{@expiration_interval}, expiration_interval_unit:"\ " #{@expiration_interval_unit}, auto_create_signup_page: #{@auto_create_signup_page},"\ " tax_code: #{@tax_code}, additional_properties: #{get_additional_properties}>" end |