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 ⇒ String
A string representing the trial interval unit for this product, either month or day.
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.
Methods inherited from BaseModel
#check_for_conflict, #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.
137 138 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 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 137 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
82 83 84 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 82 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.
72 73 74 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 72 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
77 78 79 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 77 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, please 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 the Avalara service to tax based on locale. This attribute has a max length of 10 characters.
88 89 90 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 88 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 ⇒ String
A string representing the trial interval unit for this product, either month or day
66 67 68 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 66 def trial_type @trial_type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 169 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.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 91 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
130 131 132 133 134 135 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 130 def self.nullables %w[ trial_interval_unit expiration_interval_unit ] end |
.optionals ⇒ Object
An array for optional fields
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 113 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 |