Class: AdvancedBilling::TaxConfiguration

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

Overview

TaxConfiguration Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(kind: TaxConfigurationKind::CUSTOM, destination_address: SKIP, fully_configured: false, additional_properties: {}) ⇒ TaxConfiguration

Returns a new instance of TaxConfiguration.



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/advanced_billing/models/tax_configuration.rb', line 49

def initialize(kind: TaxConfigurationKind::CUSTOM,
               destination_address: SKIP, fully_configured: false,
               additional_properties: {})
  @kind = kind unless kind == SKIP
  @destination_address = destination_address unless destination_address == SKIP
  @fully_configured = fully_configured unless fully_configured == SKIP

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end

Instance Attribute Details

#destination_addressTaxDestinationAddress

TODO: Write general description for this method



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

def destination_address
  @destination_address
end

#fully_configuredTrueClass | FalseClass

Returns ‘true` when Chargify has been properly configured to charge tax using the specified tax system. More details about taxes: maxio.zendesk.com/hc/en-us/articles/24287012608909-Taxes-Overview

Returns:

  • (TrueClass | FalseClass)


24
25
26
# File 'lib/advanced_billing/models/tax_configuration.rb', line 24

def fully_configured
  @fully_configured
end

#kindTaxConfigurationKind

TODO: Write general description for this method



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

def kind
  @kind
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/advanced_billing/models/tax_configuration.rb', line 63

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  kind = hash['kind'] ||= TaxConfigurationKind::CUSTOM
  destination_address =
    hash.key?('destination_address') ? hash['destination_address'] : SKIP
  fully_configured = hash['fully_configured'] ||= false

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  TaxConfiguration.new(kind: kind,
                       destination_address: destination_address,
                       fully_configured: fully_configured,
                       additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



27
28
29
30
31
32
33
# File 'lib/advanced_billing/models/tax_configuration.rb', line 27

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['kind'] = 'kind'
  @_hash['destination_address'] = 'destination_address'
  @_hash['fully_configured'] = 'fully_configured'
  @_hash
end

.nullablesObject

An array for nullable fields



45
46
47
# File 'lib/advanced_billing/models/tax_configuration.rb', line 45

def self.nullables
  []
end

.optionalsObject

An array for optional fields



36
37
38
39
40
41
42
# File 'lib/advanced_billing/models/tax_configuration.rb', line 36

def self.optionals
  %w[
    kind
    destination_address
    fully_configured
  ]
end