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

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #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, additional_properties: {}) ⇒ UpdateComponent

Returns a new instance of UpdateComponent.



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/advanced_billing/models/update_component.rb', line 96

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, additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @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 credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided. Available values: ‘full`, `prorated`, `none`.

Returns:



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

def upgrade_charge
  @upgrade_charge
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/advanced_billing/models/update_component.rb', line 117

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

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

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

.namesObject

A mapping from model property names to API property names.



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

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



86
87
88
89
90
91
92
93
94
# File 'lib/advanced_billing/models/update_component.rb', line 86

def self.nullables
  %w[
    description
    accounting_code
    tax_code
    item_category
    upgrade_charge
  ]
end

.optionalsObject

An array for optional fields



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

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