Class: AdvancedBilling::CreateOrUpdateProduct

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

Overview

CreateOrUpdateProduct Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(name = nil, description = nil, price_in_cents = nil, interval = nil, interval_unit = nil, handle = SKIP, accounting_code = SKIP, require_credit_card = SKIP, auto_create_signup_page = SKIP, tax_code = SKIP) ⇒ CreateOrUpdateProduct

Returns a new instance of CreateOrUpdateProduct.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 84

def initialize(name = nil, description = nil, price_in_cents = nil,
               interval = nil, interval_unit = nil, handle = SKIP,
               accounting_code = SKIP, require_credit_card = SKIP,
                = SKIP, tax_code = SKIP)
  @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
  @auto_create_signup_page =  unless  == SKIP
  @tax_code = tax_code unless tax_code == SKIP
end

Instance Attribute Details

#accounting_codeString

TODO: Write general description for this method

Returns:

  • (String)


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

def accounting_code
  @accounting_code
end

#auto_create_signup_pageTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


46
47
48
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 46

def 
  @auto_create_signup_page
end

#descriptionString

TODO: Write general description for this method

Returns:

  • (String)


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

def description
  @description
end

#handleString

TODO: Write general description for this method

Returns:

  • (String)


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

def handle
  @handle
end

#intervalInteger

TODO: Write general description for this method

Returns:

  • (Integer)


38
39
40
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 38

def interval
  @interval
end

#interval_unitString

TODO: Write general description for this method

Returns:

  • (String)


42
43
44
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 42

def interval_unit
  @interval_unit
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


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

def name
  @name
end

#price_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


34
35
36
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 34

def price_in_cents
  @price_in_cents
end

#require_credit_cardTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


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

def require_credit_card
  @require_credit_card
end

#tax_codeString

TODO: Write general description for this method

Returns:

  • (String)


50
51
52
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 50

def tax_code
  @tax_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
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 101

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
   =
    hash.key?('auto_create_signup_page') ? hash['auto_create_signup_page'] : SKIP
  tax_code = hash.key?('tax_code') ? hash['tax_code'] : SKIP

  # Create object from extracted values.
  CreateOrUpdateProduct.new(name,
                            description,
                            price_in_cents,
                            interval,
                            interval_unit,
                            handle,
                            accounting_code,
                            require_credit_card,
                            ,
                            tax_code)
end

.namesObject

A mapping from model property names to API property names.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 53

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['auto_create_signup_page'] = 'auto_create_signup_page'
  @_hash['tax_code'] = 'tax_code'
  @_hash
end

.nullablesObject

An array for nullable fields



80
81
82
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 80

def self.nullables
  []
end

.optionalsObject

An array for optional fields



69
70
71
72
73
74
75
76
77
# File 'lib/advanced_billing/models/create_or_update_product.rb', line 69

def self.optionals
  %w[
    handle
    accounting_code
    require_credit_card
    auto_create_signup_page
    tax_code
  ]
end