Class: AdvancedBilling::UpdateComponent

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

Overview

UpdateComponent Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(handle = SKIP, name = SKIP, description = SKIP, accounting_code = SKIP, taxable = SKIP, tax_code = SKIP, item_category = SKIP, display_on_hosted_page = SKIP, upgrade_charge = SKIP) ⇒ UpdateComponent

Returns a new instance of UpdateComponent.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/advanced_billing/models/update_component.rb', line 92

def initialize(handle = SKIP, name = SKIP, description = SKIP,
               accounting_code = SKIP, taxable = SKIP, tax_code = SKIP,
               item_category = SKIP, display_on_hosted_page = SKIP,
               upgrade_charge = SKIP)
  @handle = handle unless handle == SKIP
  @name = name unless name == SKIP
  @description = description unless description == SKIP
  @accounting_code = accounting_code unless accounting_code == SKIP
  @taxable = taxable unless taxable == SKIP
  @tax_code = tax_code unless tax_code == SKIP
  @item_category = item_category unless item_category == SKIP
  @display_on_hosted_page = display_on_hosted_page unless display_on_hosted_page == SKIP
  @upgrade_charge = upgrade_charge unless upgrade_charge == SKIP
end

Instance Attribute Details

#accounting_codeString

The description of the component.

Returns:

  • (String)


27
28
29
# File 'lib/advanced_billing/models/update_component.rb', line 27

def accounting_code
  @accounting_code
end

#descriptionString

The description of the component.

Returns:

  • (String)


23
24
25
# File 'lib/advanced_billing/models/update_component.rb', line 23

def description
  @description
end

#display_on_hosted_pageTrueClass | FalseClass

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

Returns:

  • (TrueClass | FalseClass)


47
48
49
# File 'lib/advanced_billing/models/update_component.rb', line 47

def display_on_hosted_page
  @display_on_hosted_page
end

#handleString

TODO: Write general description for this method

Returns:

  • (String)


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

def handle
  @handle
end

#item_categoryItemCategory

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

Returns:



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

def item_category
  @item_category
end

#nameString

The name of the Component, suitable for display on statements. i.e. Text Messages.

Returns:

  • (String)


19
20
21
# File 'lib/advanced_billing/models/update_component.rb', line 19

def name
  @name
end

#tax_codeString

A string representing the tax code related to the component type. This is especially important when using the Avalara service to tax based on locale. This attribute has a max length of 10 characters.

Returns:

  • (String)


37
38
39
# File 'lib/advanced_billing/models/update_component.rb', line 37

def tax_code
  @tax_code
end

#taxableTrueClass | FalseClass

Boolean flag describing whether a component is taxable or not.

Returns:

  • (TrueClass | FalseClass)


31
32
33
# File 'lib/advanced_billing/models/update_component.rb', line 31

def taxable
  @taxable
end

#upgrade_chargeCreditType

The type of charge to be applied when a component is upgraded. Valid values are: ‘prorated`, `full`, `none`.

Returns:



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

def upgrade_charge
  @upgrade_charge
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  handle = hash.key?('handle') ? hash['handle'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP
  accounting_code =
    hash.key?('accounting_code') ? hash['accounting_code'] : SKIP
  taxable = hash.key?('taxable') ? hash['taxable'] : SKIP
  tax_code = hash.key?('tax_code') ? hash['tax_code'] : SKIP
  item_category = hash.key?('item_category') ? hash['item_category'] : SKIP
  display_on_hosted_page =
    hash.key?('display_on_hosted_page') ? hash['display_on_hosted_page'] : SKIP
  upgrade_charge =
    hash.key?('upgrade_charge') ? hash['upgrade_charge'] : SKIP

  # Create object from extracted values.
  UpdateComponent.new(handle,
                      name,
                      description,
                      accounting_code,
                      taxable,
                      tax_code,
                      item_category,
                      display_on_hosted_page,
                      upgrade_charge)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['handle'] = 'handle'
  @_hash['name'] = 'name'
  @_hash['description'] = 'description'
  @_hash['accounting_code'] = 'accounting_code'
  @_hash['taxable'] = 'taxable'
  @_hash['tax_code'] = 'tax_code'
  @_hash['item_category'] = 'item_category'
  @_hash['display_on_hosted_page'] = 'display_on_hosted_page'
  @_hash['upgrade_charge'] = 'upgrade_charge'
  @_hash
end

.nullablesObject

An array for nullable fields



85
86
87
88
89
90
# File 'lib/advanced_billing/models/update_component.rb', line 85

def self.nullables
  %w[
    description
    tax_code
  ]
end

.optionalsObject

An array for optional fields



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/advanced_billing/models/update_component.rb', line 70

def self.optionals
  %w[
    handle
    name
    description
    accounting_code
    taxable
    tax_code
    item_category
    display_on_hosted_page
    upgrade_charge
  ]
end