Class: NewStoreApi::TenantConfigDto

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

Overview

TenantConfigDto 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(created_at = nil, fixed_rate = nil, tax_calculation_strategy = nil, tenant = nil, updated_at = nil, updated_by = nil, version = nil, avalara = SKIP, custom = SKIP, fixed_rate_per_country = SKIP, is_deleted = SKIP, tax_committing_enabled = SKIP, vertex = SKIP) ⇒ TenantConfigDto

Returns a new instance of TenantConfigDto.



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 135

def initialize(created_at = nil, fixed_rate = nil,
               tax_calculation_strategy = nil, tenant = nil,
               updated_at = nil, updated_by = nil, version = nil,
               avalara = SKIP, custom = SKIP, fixed_rate_per_country = SKIP,
               is_deleted = SKIP, tax_committing_enabled = SKIP,
               vertex = SKIP)
  @avalara = avalara unless avalara == SKIP
  @created_at = created_at
  @custom = custom unless custom == SKIP
  @fixed_rate = fixed_rate
  @fixed_rate_per_country = fixed_rate_per_country unless fixed_rate_per_country == SKIP
  @is_deleted = is_deleted unless is_deleted == SKIP
  @tax_calculation_strategy = tax_calculation_strategy
  @tax_committing_enabled = tax_committing_enabled unless tax_committing_enabled == SKIP
  @tenant = tenant
  @updated_at = updated_at
  @updated_by = updated_by
  @version = version
  @vertex = vertex unless vertex == SKIP
end

Instance Attribute Details

#avalaraAvalaraConfigDto

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.

Returns:



21
22
23
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 21

def avalara
  @avalara
end

#created_atDateTime

Creation date of the configuration.

Returns:

  • (DateTime)


25
26
27
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 25

def created_at
  @created_at
end

#customCustomConfigDto

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.

Returns:



32
33
34
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 32

def custom
  @custom
end

#fixed_rateFixedRateConfigDto

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.

Returns:



43
44
45
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 43

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:



56
57
58
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 56

def fixed_rate_per_country
  @fixed_rate_per_country
end

#is_deletedTrueClass | FalseClass

Flag that indicates if the configuration was deleted.

Returns:

  • (TrueClass | FalseClass)


60
61
62
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 60

def is_deleted
  @is_deleted
end

#tax_calculation_strategyTaxCalculationStrategyEnum

Flag that indicates if the configuration was deleted.



64
65
66
# File 'lib/new_store_api/models/tenant_config_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_dto.rb', line 69

def tax_committing_enabled
  @tax_committing_enabled
end

#tenantString

Tenant identifier.

Returns:

  • (String)


73
74
75
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 73

def tenant
  @tenant
end

#updated_atDateTime

Latest update date of the configuration.

Returns:

  • (DateTime)


77
78
79
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 77

def updated_at
  @updated_at
end

#updated_byString

Identifier of the user who updated the current version of the configuration.

Returns:

  • (String)


82
83
84
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 82

def updated_by
  @updated_by
end

#versionInteger

Version number of the config.

  • Version number 0 represents the system defaults.

Returns:

  • (Integer)


87
88
89
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 87

def version
  @version
end

#vertexVertexConfigDto

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.

Returns:



97
98
99
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 97

def vertex
  @vertex
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 157

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               end
  fixed_rate = FixedRateConfigDto.from_hash(hash['fixed_rate']) if hash['fixed_rate']
  tax_calculation_strategy =
    hash.key?('tax_calculation_strategy') ? hash['tax_calculation_strategy'] : nil
  tenant = hash.key?('tenant') ? hash['tenant'] : nil
  updated_at = if hash.key?('updated_at')
                 (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at'])
               end
  updated_by = hash.key?('updated_by') ? hash['updated_by'] : nil
  version = hash.key?('version') ? hash['version'] : nil
  avalara = AvalaraConfigDto.from_hash(hash['avalara']) if hash['avalara']
  custom = CustomConfigDto.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')
  is_deleted = hash.key?('is_deleted') ? hash['is_deleted'] : SKIP
  tax_committing_enabled =
    hash.key?('tax_committing_enabled') ? hash['tax_committing_enabled'] : SKIP
  vertex = VertexConfigDto.from_hash(hash['vertex']) if hash['vertex']

  # Create object from extracted values.
  TenantConfigDto.new(created_at,
                      fixed_rate,
                      tax_calculation_strategy,
                      tenant,
                      updated_at,
                      updated_by,
                      version,
                      avalara,
                      custom,
                      fixed_rate_per_country,
                      is_deleted,
                      tax_committing_enabled,
                      vertex)
end

.namesObject

A mapping from model property names to API property names.



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 100

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['avalara'] = 'avalara'
  @_hash['created_at'] = 'created_at'
  @_hash['custom'] = 'custom'
  @_hash['fixed_rate'] = 'fixed_rate'
  @_hash['fixed_rate_per_country'] = 'fixed_rate_per_country'
  @_hash['is_deleted'] = 'is_deleted'
  @_hash['tax_calculation_strategy'] = 'tax_calculation_strategy'
  @_hash['tax_committing_enabled'] = 'tax_committing_enabled'
  @_hash['tenant'] = 'tenant'
  @_hash['updated_at'] = 'updated_at'
  @_hash['updated_by'] = 'updated_by'
  @_hash['version'] = 'version'
  @_hash['vertex'] = 'vertex'
  @_hash
end

.nullablesObject

An array for nullable fields



131
132
133
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 131

def self.nullables
  []
end

.optionalsObject

An array for optional fields



119
120
121
122
123
124
125
126
127
128
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 119

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



219
220
221
222
223
224
225
226
227
228
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 219

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

#to_custom_created_atObject



200
201
202
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 200

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_updated_atObject



204
205
206
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 204

def to_custom_updated_at
  DateTimeHelper.to_rfc3339(updated_at)
end

#to_sObject

Provides a human-readable string representation of the object.



209
210
211
212
213
214
215
216
# File 'lib/new_store_api/models/tenant_config_dto.rb', line 209

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