Class: NewStoreApi::TenantConfigCreateDto

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/tenant_config_create_dto.rb

Overview

TenantConfigCreateDto 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(fixed_rate = nil, tax_calculation_strategy = nil, avalara = SKIP, custom = SKIP, fixed_rate_per_country = SKIP, tax_committing_enabled = SKIP, vertex = SKIP) ⇒ TenantConfigCreateDto

Returns a new instance of TenantConfigCreateDto.



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/new_store_api/models/tenant_config_create_dto.rb', line 110

def initialize(fixed_rate = nil, tax_calculation_strategy = nil,
               avalara = SKIP, custom = SKIP, fixed_rate_per_country = SKIP,
               tax_committing_enabled = SKIP, vertex = SKIP)
  @avalara = avalara unless avalara == SKIP
  @custom = custom unless custom == SKIP
  @fixed_rate = fixed_rate
  @fixed_rate_per_country = fixed_rate_per_country unless fixed_rate_per_country == SKIP
  @tax_calculation_strategy = tax_calculation_strategy
  @tax_committing_enabled = tax_committing_enabled unless tax_committing_enabled == SKIP
  @vertex = vertex unless vertex == SKIP
end

Instance Attribute Details

#avalaraAvalaraConfigCreateDto

Avalara configuration.

  • Required if the tax_calculation_strategy is set to avalara.
  • If the tax calculation strategy is set to avalara, the given configuration will be used.
  • If the Avalara configuration is defined, the configuration will be validated through a ping request to Avalara, which will validate the authenticity of Avalara credentials.


20
21
22
# File 'lib/new_store_api/models/tenant_config_create_dto.rb', line 20

def avalara
  @avalara
end

#customCustomConfigCreateDto

Custom provider configuration.

  • Required if the tax_calculation_strategy is set to custom.
  • If the tax calculation strategy is set to custom, the given configuration will be used.


27
28
29
# File 'lib/new_store_api/models/tenant_config_create_dto.rb', line 27

def custom
  @custom
end

#fixed_rateFixedRateConfigCreateDto

Fixed rate configuration.

  • If the tax calculation strategy is set to fixedrate, the specified tax rate will be used.
  • For the other tax calculation strategies, the specified rate will be used as a fallback if the tax calculation fails (e.g. if the tax provider is not reachable).
  • The specified rate will be used as a fallback by the Associate App in offline-mode.


38
39
40
# File 'lib/new_store_api/models/tenant_config_create_dto.rb', line 38

def fixed_rate
  @fixed_rate
end

#fixed_rate_per_countryHash[String, FixedRateConfigCreateDto]

Fixed rate configuration per country.

  • Uses ISO 3166 Alpha-2 format as the key in upper-case.
  • Fixed rate specification can be defined under each country key for the desired countries.
  • If the tax calculation strategy is set to fixed_rate_per_country:
    • Fixed rate configuration must be configured.
    • The specified tax rate will be used if the country code of the store has a fixed rate configuration.
    • The tax calculation will fail if the country code of the store does not have a fixed rate configuration.

Returns:



51
52
53
# File 'lib/new_store_api/models/tenant_config_create_dto.rb', line 51

def fixed_rate_per_country
  @fixed_rate_per_country
end

#tax_calculation_strategyTaxCalculationStrategyEnum

Fixed rate configuration per country.

  • Uses ISO 3166 Alpha-2 format as the key in upper-case.
  • Fixed rate specification can be defined under each country key for the desired countries.
  • If the tax calculation strategy is set to fixed_rate_per_country:
    • Fixed rate configuration must be configured.
    • The specified tax rate will be used if the country code of the store has a fixed rate configuration.
    • The tax calculation will fail if the country code of the store does not have a fixed rate configuration.


64
65
66
# File 'lib/new_store_api/models/tenant_config_create_dto.rb', line 64

def tax_calculation_strategy
  @tax_calculation_strategy
end

#tax_committing_enabledTrueClass | FalseClass

Enable tax committing to the selected tax calculation strategy. The tax committing feature is only supported for in-store orders.

Returns:

  • (TrueClass | FalseClass)


69
70
71
# File 'lib/new_store_api/models/tenant_config_create_dto.rb', line 69

def tax_committing_enabled
  @tax_committing_enabled
end

#vertexVertexConfigCreateDto

Vertex configuration.

  • Required if the tax_calculation_strategy is set to vertex.
  • If the tax calculation strategy is set to vertex, the given configuration will be used.
  • If the Vertex configuration is defined, the configuration will be validated through a ping request to Vertex, which will validate the authenticity of Vertex credentials.


79
80
81
# File 'lib/new_store_api/models/tenant_config_create_dto.rb', line 79

def vertex
  @vertex
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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/new_store_api/models/tenant_config_create_dto.rb', line 123

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  fixed_rate = FixedRateConfigCreateDto.from_hash(hash['fixed_rate']) if hash['fixed_rate']
  tax_calculation_strategy =
    hash.key?('tax_calculation_strategy') ? hash['tax_calculation_strategy'] : nil
  avalara = AvalaraConfigCreateDto.from_hash(hash['avalara']) if hash['avalara']
  custom = CustomConfigCreateDto.from_hash(hash['custom']) if hash['custom']
  fixed_rate_per_country = FixedRateConfigCreateDto.from_hash(hash['fixed_rate_per_country']) if
    hash['fixed_rate_per_country']

  fixed_rate_per_country = SKIP unless hash.key?('fixed_rate_per_country')
  tax_committing_enabled =
    hash.key?('tax_committing_enabled') ? hash['tax_committing_enabled'] : SKIP
  vertex = VertexConfigCreateDto.from_hash(hash['vertex']) if hash['vertex']

  # Create object from extracted values.
  TenantConfigCreateDto.new(fixed_rate,
                            tax_calculation_strategy,
                            avalara,
                            custom,
                            fixed_rate_per_country,
                            tax_committing_enabled,
                            vertex)
end

.namesObject

A mapping from model property names to API property names.



82
83
84
85
86
87
88
89
90
91
92
# File 'lib/new_store_api/models/tenant_config_create_dto.rb', line 82

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['avalara'] = 'avalara'
  @_hash['custom'] = 'custom'
  @_hash['fixed_rate'] = 'fixed_rate'
  @_hash['fixed_rate_per_country'] = 'fixed_rate_per_country'
  @_hash['tax_calculation_strategy'] = 'tax_calculation_strategy'
  @_hash['tax_committing_enabled'] = 'tax_committing_enabled'
  @_hash['vertex'] = 'vertex'
  @_hash
end

.nullablesObject

An array for nullable fields



106
107
108
# File 'lib/new_store_api/models/tenant_config_create_dto.rb', line 106

def self.nullables
  []
end

.optionalsObject

An array for optional fields



95
96
97
98
99
100
101
102
103
# File 'lib/new_store_api/models/tenant_config_create_dto.rb', line 95

def self.optionals
  %w[
    avalara
    custom
    fixed_rate_per_country
    tax_committing_enabled
    vertex
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



160
161
162
163
164
165
166
# File 'lib/new_store_api/models/tenant_config_create_dto.rb', line 160

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} avalara: #{@avalara.inspect}, custom: #{@custom.inspect}, fixed_rate:"\
  " #{@fixed_rate.inspect}, fixed_rate_per_country: #{@fixed_rate_per_country.inspect},"\
  " tax_calculation_strategy: #{@tax_calculation_strategy.inspect}, tax_committing_enabled:"\
  " #{@tax_committing_enabled.inspect}, vertex: #{@vertex.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



151
152
153
154
155
156
157
# File 'lib/new_store_api/models/tenant_config_create_dto.rb', line 151

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} avalara: #{@avalara}, custom: #{@custom}, fixed_rate: #{@fixed_rate},"\
  " fixed_rate_per_country: #{@fixed_rate_per_country}, tax_calculation_strategy:"\
  " #{@tax_calculation_strategy}, tax_committing_enabled: #{@tax_committing_enabled}, vertex:"\
  " #{@vertex}>"
end