Class: AdvancedBilling::Product

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/product.rb

Overview

Product Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(id = SKIP, name = SKIP, handle = SKIP, description = SKIP, accounting_code = SKIP, request_credit_card = SKIP, expiration_interval = SKIP, expiration_interval_unit = SKIP, created_at = SKIP, updated_at = SKIP, price_in_cents = SKIP, interval = SKIP, interval_unit = SKIP, initial_charge_in_cents = SKIP, trial_price_in_cents = SKIP, trial_interval = SKIP, trial_interval_unit = SKIP, archived_at = SKIP, require_credit_card = SKIP, return_params = SKIP, taxable = SKIP, update_return_url = SKIP, initial_charge_after_trial = SKIP, version_number = SKIP, update_return_params = SKIP, product_family = SKIP, public_signup_pages = SKIP, product_price_point_name = SKIP, request_billing_address = SKIP, require_billing_address = SKIP, require_shipping_address = SKIP, tax_code = SKIP, default_product_price_point_id = SKIP, use_site_exchange_rate = SKIP, item_category = SKIP, product_price_point_id = SKIP, product_price_point_handle = SKIP) ⇒ Product



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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/advanced_billing/models/product.rb', line 310

def initialize(id = SKIP, name = SKIP, handle = SKIP, description = SKIP,
               accounting_code = SKIP, request_credit_card = SKIP,
               expiration_interval = SKIP, expiration_interval_unit = SKIP,
               created_at = SKIP, updated_at = SKIP, price_in_cents = SKIP,
               interval = SKIP, interval_unit = SKIP,
               initial_charge_in_cents = SKIP, trial_price_in_cents = SKIP,
               trial_interval = SKIP, trial_interval_unit = SKIP,
               archived_at = SKIP, require_credit_card = SKIP,
               return_params = SKIP, taxable = SKIP,
               update_return_url = SKIP, initial_charge_after_trial = SKIP,
               version_number = SKIP, update_return_params = SKIP,
               product_family = SKIP,  = SKIP,
               product_price_point_name = SKIP,
               request_billing_address = SKIP,
               require_billing_address = SKIP,
               require_shipping_address = SKIP, tax_code = SKIP,
               default_product_price_point_id = SKIP,
               use_site_exchange_rate = SKIP, item_category = SKIP,
               product_price_point_id = SKIP,
               product_price_point_handle = SKIP)
  @id = id unless id == SKIP
  @name = name unless name == SKIP
  @handle = handle unless handle == SKIP
  @description = description unless description == SKIP
  @accounting_code = accounting_code unless accounting_code == SKIP
  @request_credit_card = request_credit_card unless request_credit_card == SKIP
  @expiration_interval = expiration_interval unless expiration_interval == SKIP
  @expiration_interval_unit = expiration_interval_unit unless expiration_interval_unit == SKIP
  @created_at = created_at unless created_at == SKIP
  @updated_at = updated_at unless updated_at == 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
  @initial_charge_in_cents = initial_charge_in_cents unless initial_charge_in_cents == 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
  @archived_at = archived_at unless archived_at == SKIP
  @require_credit_card = require_credit_card unless require_credit_card == SKIP
  @return_params = return_params unless return_params == SKIP
  @taxable = taxable unless taxable == SKIP
  @update_return_url = update_return_url unless update_return_url == SKIP
  unless initial_charge_after_trial == SKIP
    @initial_charge_after_trial =
      initial_charge_after_trial
  end
  @version_number = version_number unless version_number == SKIP
  @update_return_params = update_return_params unless update_return_params == SKIP
  @product_family = product_family unless product_family == SKIP
   =  unless  == SKIP
  @product_price_point_name = product_price_point_name unless product_price_point_name == SKIP
  @request_billing_address = request_billing_address unless request_billing_address == SKIP
  @require_billing_address = require_billing_address unless require_billing_address == SKIP
  @require_shipping_address = require_shipping_address unless require_shipping_address == SKIP
  @tax_code = tax_code unless tax_code == SKIP
  unless default_product_price_point_id == SKIP
    @default_product_price_point_id =
      default_product_price_point_id
  end
  @use_site_exchange_rate = use_site_exchange_rate unless use_site_exchange_rate == SKIP
  @item_category = item_category unless item_category == SKIP
  @product_price_point_id = product_price_point_id unless product_price_point_id == SKIP
  unless product_price_point_handle == SKIP
    @product_price_point_handle =
      product_price_point_handle
  end
end

Instance Attribute Details

#accounting_codeString

E.g. Internal ID or SKU Number



30
31
32
# File 'lib/advanced_billing/models/product.rb', line 30

def accounting_code
  @accounting_code
end

#archived_atString

Timestamp indicating when this product was archived



94
95
96
# File 'lib/advanced_billing/models/product.rb', line 94

def archived_at
  @archived_at
end

#created_atString

Timestamp indicating when this product was created



52
53
54
# File 'lib/advanced_billing/models/product.rb', line 52

def created_at
  @created_at
end

#default_product_price_point_idInteger

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.



178
179
180
# File 'lib/advanced_billing/models/product.rb', line 178

def default_product_price_point_id
  @default_product_price_point_id
end

#descriptionString

The product description



26
27
28
# File 'lib/advanced_billing/models/product.rb', line 26

def description
  @description
end

#expiration_intervalInteger

A numerical interval for the length a subscription to this product will run before it expires. See the description of interval for a description of how this value is coupled with an interval unit to calculate the full interval



43
44
45
# File 'lib/advanced_billing/models/product.rb', line 43

def expiration_interval
  @expiration_interval
end

#expiration_interval_unitExtendedIntervalUnit

A string representing the trial interval unit for this product, either month or day



48
49
50
# File 'lib/advanced_billing/models/product.rb', line 48

def expiration_interval_unit
  @expiration_interval_unit
end

#handleString

The product API handle



22
23
24
# File 'lib/advanced_billing/models/product.rb', line 22

def handle
  @handle
end

#idInteger

TODO: Write general description for this method



14
15
16
# File 'lib/advanced_billing/models/product.rb', line 14

def id
  @id
end

#initial_charge_after_trialTrueClass | FalseClass

The url to which a customer will be returned after a successful account update



119
120
121
# File 'lib/advanced_billing/models/product.rb', line 119

def initial_charge_after_trial
  @initial_charge_after_trial
end

#initial_charge_in_centsInteger

The up front charge you have specified.



74
75
76
# File 'lib/advanced_billing/models/product.rb', line 74

def initial_charge_in_cents
  @initial_charge_in_cents
end

#intervalInteger

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



65
66
67
# File 'lib/advanced_billing/models/product.rb', line 65

def interval
  @interval
end

#interval_unitIntervalUnit

A string representing the interval unit for this product, either month or day



70
71
72
# File 'lib/advanced_billing/models/product.rb', line 70

def interval_unit
  @interval_unit
end

#item_categoryString

One of the following: Business Software, Consumer Software, Digital Services, Physical Goods, Other



189
190
191
# File 'lib/advanced_billing/models/product.rb', line 189

def item_category
  @item_category
end

#nameString

The product name



18
19
20
# File 'lib/advanced_billing/models/product.rb', line 18

def name
  @name
end

#price_in_centsInteger

The product price, in integer cents



60
61
62
# File 'lib/advanced_billing/models/product.rb', line 60

def price_in_cents
  @price_in_cents
end

#product_familyProductFamily

The parameters will append to the url after a successful account update. See [help documentation](help.chargify.com/products/product-editing.html#ret urn-parameters-after-account-update)



137
138
139
# File 'lib/advanced_billing/models/product.rb', line 137

def product_family
  @product_family
end

#product_price_point_handleString

One of the following: Business Software, Consumer Software, Digital Services, Physical Goods, Other



199
200
201
# File 'lib/advanced_billing/models/product.rb', line 199

def product_price_point_handle
  @product_price_point_handle
end

#product_price_point_idInteger

One of the following: Business Software, Consumer Software, Digital Services, Physical Goods, Other



194
195
196
# File 'lib/advanced_billing/models/product.rb', line 194

def product_price_point_id
  @product_price_point_id
end

#product_price_point_nameString

The parameters will append to the url after a successful account update. See [help documentation](help.chargify.com/products/product-editing.html#ret urn-parameters-after-account-update)



151
152
153
# File 'lib/advanced_billing/models/product.rb', line 151

def product_price_point_name
  @product_price_point_name
end

#public_signup_pagesArray[PublicSignupPage]

The parameters will append to the url after a successful account update. See [help documentation](help.chargify.com/products/product-editing.html#ret urn-parameters-after-account-update)



144
145
146
# File 'lib/advanced_billing/models/product.rb', line 144

def 
  
end

#request_billing_addressTrueClass | FalseClass

A boolean indicating whether to request a billing address on any Self-Service Pages that are used by subscribers of this product.



156
157
158
# File 'lib/advanced_billing/models/product.rb', line 156

def request_billing_address
  @request_billing_address
end

#request_credit_cardTrueClass | 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.



36
37
38
# File 'lib/advanced_billing/models/product.rb', line 36

def request_credit_card
  @request_credit_card
end

#require_billing_addressTrueClass | FalseClass

A boolean indicating whether a billing address is required to add a payment profile, especially at signup.



161
162
163
# File 'lib/advanced_billing/models/product.rb', line 161

def require_billing_address
  @require_billing_address
end

#require_credit_cardTrueClass | FalseClass

Boolean that controls whether a payment profile is required to be entered for customers wishing to sign up on this product.



99
100
101
# File 'lib/advanced_billing/models/product.rb', line 99

def require_credit_card
  @require_credit_card
end

#require_shipping_addressTrueClass | FalseClass

A boolean indicating whether a shipping address is required for the customer, especially at signup.



166
167
168
# File 'lib/advanced_billing/models/product.rb', line 166

def require_shipping_address
  @require_shipping_address
end

#return_paramsString

Boolean that controls whether a payment profile is required to be entered for customers wishing to sign up on this product.



104
105
106
# File 'lib/advanced_billing/models/product.rb', line 104

def return_params
  @return_params
end

#tax_codeString

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.



172
173
174
# File 'lib/advanced_billing/models/product.rb', line 172

def tax_code
  @tax_code
end

#taxableTrueClass | FalseClass

Boolean that controls whether a payment profile is required to be entered for customers wishing to sign up on this product.



109
110
111
# File 'lib/advanced_billing/models/product.rb', line 109

def taxable
  @taxable
end

#trial_intervalInteger

A numerical interval for the length of the trial period of a subscription to this product. See the description of interval for a description of how this value is coupled with an interval unit to calculate the full interval



85
86
87
# File 'lib/advanced_billing/models/product.rb', line 85

def trial_interval
  @trial_interval
end

#trial_interval_unitIntervalUnit

A string representing the trial interval unit for this product, either month or day



90
91
92
# File 'lib/advanced_billing/models/product.rb', line 90

def trial_interval_unit
  @trial_interval_unit
end

#trial_price_in_centsInteger

The price of the trial period for a subscription to this product, in integer cents.



79
80
81
# File 'lib/advanced_billing/models/product.rb', line 79

def trial_price_in_cents
  @trial_price_in_cents
end

#update_return_paramsString

The parameters will append to the url after a successful account update. See [help documentation](help.chargify.com/products/product-editing.html#ret urn-parameters-after-account-update)



130
131
132
# File 'lib/advanced_billing/models/product.rb', line 130

def update_return_params
  @update_return_params
end

#update_return_urlString

The url to which a customer will be returned after a successful account update



114
115
116
# File 'lib/advanced_billing/models/product.rb', line 114

def update_return_url
  @update_return_url
end

#updated_atString

Timestamp indicating when this product was last updated



56
57
58
# File 'lib/advanced_billing/models/product.rb', line 56

def updated_at
  @updated_at
end

#use_site_exchange_rateTrueClass | FalseClass

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.



184
185
186
# File 'lib/advanced_billing/models/product.rb', line 184

def use_site_exchange_rate
  @use_site_exchange_rate
end

#version_numberInteger

The version of the product



123
124
125
# File 'lib/advanced_billing/models/product.rb', line 123

def version_number
  @version_number
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# File 'lib/advanced_billing/models/product.rb', line 379

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
  description = hash.key?('description') ? hash['description'] : SKIP
  accounting_code =
    hash.key?('accounting_code') ? hash['accounting_code'] : SKIP
  request_credit_card =
    hash.key?('request_credit_card') ? hash['request_credit_card'] : SKIP
  expiration_interval =
    hash.key?('expiration_interval') ? hash['expiration_interval'] : SKIP
  expiration_interval_unit = hash.key?('expiration_interval_unit') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:ProductExpirationIntervalUnit), hash['expiration_interval_unit']
  ) : SKIP
  created_at = hash.key?('created_at') ? hash['created_at'] : SKIP
  updated_at = hash.key?('updated_at') ? hash['updated_at'] : 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') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:ProductIntervalUnit), hash['interval_unit']
  ) : SKIP
  initial_charge_in_cents =
    hash.key?('initial_charge_in_cents') ? hash['initial_charge_in_cents'] : 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') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:ProductTrialIntervalUnit), hash['trial_interval_unit']
  ) : SKIP
  archived_at = hash.key?('archived_at') ? hash['archived_at'] : SKIP
  require_credit_card =
    hash.key?('require_credit_card') ? hash['require_credit_card'] : SKIP
  return_params = hash.key?('return_params') ? hash['return_params'] : SKIP
  taxable = hash.key?('taxable') ? hash['taxable'] : SKIP
  update_return_url =
    hash.key?('update_return_url') ? hash['update_return_url'] : SKIP
  initial_charge_after_trial =
    hash.key?('initial_charge_after_trial') ? hash['initial_charge_after_trial'] : SKIP
  version_number =
    hash.key?('version_number') ? hash['version_number'] : SKIP
  update_return_params =
    hash.key?('update_return_params') ? hash['update_return_params'] : SKIP
  product_family = ProductFamily.from_hash(hash['product_family']) if hash['product_family']
  # Parameter is an array, so we need to iterate through it

   = nil
  unless hash['public_signup_pages'].nil?
     = []
    hash['public_signup_pages'].each do |structure|
       << (PublicSignupPage.from_hash(structure) if structure)
    end
  end

   = SKIP unless hash.key?('public_signup_pages')
  product_price_point_name =
    hash.key?('product_price_point_name') ? hash['product_price_point_name'] : SKIP
  request_billing_address =
    hash.key?('request_billing_address') ? hash['request_billing_address'] : SKIP
  require_billing_address =
    hash.key?('require_billing_address') ? hash['require_billing_address'] : SKIP
  require_shipping_address =
    hash.key?('require_shipping_address') ? hash['require_shipping_address'] : SKIP
  tax_code = hash.key?('tax_code') ? hash['tax_code'] : SKIP
  default_product_price_point_id =
    hash.key?('default_product_price_point_id') ? hash['default_product_price_point_id'] : SKIP
  use_site_exchange_rate =
    hash.key?('use_site_exchange_rate') ? hash['use_site_exchange_rate'] : SKIP
  item_category = hash.key?('item_category') ? hash['item_category'] : SKIP
  product_price_point_id =
    hash.key?('product_price_point_id') ? hash['product_price_point_id'] : SKIP
  product_price_point_handle =
    hash.key?('product_price_point_handle') ? hash['product_price_point_handle'] : SKIP

  # Create object from extracted values.

  Product.new(id,
              name,
              handle,
              description,
              accounting_code,
              request_credit_card,
              expiration_interval,
              expiration_interval_unit,
              created_at,
              updated_at,
              price_in_cents,
              interval,
              interval_unit,
              initial_charge_in_cents,
              trial_price_in_cents,
              trial_interval,
              trial_interval_unit,
              archived_at,
              require_credit_card,
              return_params,
              taxable,
              update_return_url,
              initial_charge_after_trial,
              version_number,
              update_return_params,
              product_family,
              ,
              product_price_point_name,
              request_billing_address,
              require_billing_address,
              require_shipping_address,
              tax_code,
              default_product_price_point_id,
              use_site_exchange_rate,
              item_category,
              product_price_point_id,
              product_price_point_handle)
end

.namesObject

A mapping from model property names to API property names.



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
# File 'lib/advanced_billing/models/product.rb', line 202

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['name'] = 'name'
  @_hash['handle'] = 'handle'
  @_hash['description'] = 'description'
  @_hash['accounting_code'] = 'accounting_code'
  @_hash['request_credit_card'] = 'request_credit_card'
  @_hash['expiration_interval'] = 'expiration_interval'
  @_hash['expiration_interval_unit'] = 'expiration_interval_unit'
  @_hash['created_at'] = 'created_at'
  @_hash['updated_at'] = 'updated_at'
  @_hash['price_in_cents'] = 'price_in_cents'
  @_hash['interval'] = 'interval'
  @_hash['interval_unit'] = 'interval_unit'
  @_hash['initial_charge_in_cents'] = 'initial_charge_in_cents'
  @_hash['trial_price_in_cents'] = 'trial_price_in_cents'
  @_hash['trial_interval'] = 'trial_interval'
  @_hash['trial_interval_unit'] = 'trial_interval_unit'
  @_hash['archived_at'] = 'archived_at'
  @_hash['require_credit_card'] = 'require_credit_card'
  @_hash['return_params'] = 'return_params'
  @_hash['taxable'] = 'taxable'
  @_hash['update_return_url'] = 'update_return_url'
  @_hash['initial_charge_after_trial'] = 'initial_charge_after_trial'
  @_hash['version_number'] = 'version_number'
  @_hash['update_return_params'] = 'update_return_params'
  @_hash['product_family'] = 'product_family'
  @_hash['public_signup_pages'] = 'public_signup_pages'
  @_hash['product_price_point_name'] = 'product_price_point_name'
  @_hash['request_billing_address'] = 'request_billing_address'
  @_hash['require_billing_address'] = 'require_billing_address'
  @_hash['require_shipping_address'] = 'require_shipping_address'
  @_hash['tax_code'] = 'tax_code'
  @_hash['default_product_price_point_id'] =
    'default_product_price_point_id'
  @_hash['use_site_exchange_rate'] = 'use_site_exchange_rate'
  @_hash['item_category'] = 'item_category'
  @_hash['product_price_point_id'] = 'product_price_point_id'
  @_hash['product_price_point_handle'] = 'product_price_point_handle'
  @_hash
end

.nullablesObject

An array for nullable fields



289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/advanced_billing/models/product.rb', line 289

def self.nullables
  %w[
    handle
    accounting_code
    expiration_interval
    expiration_interval_unit
    initial_charge_in_cents
    trial_price_in_cents
    trial_interval
    trial_interval_unit
    archived_at
    return_params
    update_return_url
    update_return_params
    tax_code
    use_site_exchange_rate
    item_category
    product_price_point_handle
  ]
end

.optionalsObject

An array for optional fields



246
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
# File 'lib/advanced_billing/models/product.rb', line 246

def self.optionals
  %w[
    id
    name
    handle
    description
    accounting_code
    request_credit_card
    expiration_interval
    expiration_interval_unit
    created_at
    updated_at
    price_in_cents
    interval
    interval_unit
    initial_charge_in_cents
    trial_price_in_cents
    trial_interval
    trial_interval_unit
    archived_at
    require_credit_card
    return_params
    taxable
    update_return_url
    initial_charge_after_trial
    version_number
    update_return_params
    product_family
    public_signup_pages
    product_price_point_name
    request_billing_address
    require_billing_address
    require_shipping_address
    tax_code
    default_product_price_point_id
    use_site_exchange_rate
    item_category
    product_price_point_id
    product_price_point_handle
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.



498
499
500
501
502
503
504
# File 'lib/advanced_billing/models/product.rb', line 498

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end