Class: NewStoreApi::StoreConfigDto
- Defined in:
- lib/new_store_api/models/store_config_dto.rb
Overview
StoreConfigDto Model.
Instance Attribute Summary collapse
-
#avalara ⇒ AvalaraConfigDto
Avalara configuration.
-
#country_code ⇒ String
Avalara configuration.
-
#created_at ⇒ DateTime
Creation date of the configuration.
-
#custom ⇒ CustomConfigDto
Custom provider configuration.
-
#fixed_rate ⇒ FixedRateConfigDto
Fixed rate configuration.
-
#fixed_rate_per_country ⇒ Hash[String, FixedRateConfigCreateDto]
Fixed rate configuration per country.
-
#is_deleted ⇒ TrueClass | FalseClass
Flag that indicates if the configuration was deleted.
-
#store_id ⇒ String
Store identifier within the NewStore platform.
-
#tax_calculation_strategy ⇒ TaxCalculationStrategyEnum
Store identifier within the NewStore platform.
-
#tenant ⇒ String
Tenant identifier.
-
#updated_at ⇒ DateTime
Latest update date of the configuration.
-
#updated_by ⇒ String
Identifier of the user who updated the current version of the configuration.
-
#version ⇒ Integer
Version number of the config.
-
#vertex ⇒ VertexConfigDto
Vertex configuration.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(country_code = nil, created_at = nil, fixed_rate = nil, store_id = 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, vertex = SKIP) ⇒ StoreConfigDto
constructor
A new instance of StoreConfigDto.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_created_at ⇒ Object
- #to_custom_updated_at ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(country_code = nil, created_at = nil, fixed_rate = nil, store_id = 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, vertex = SKIP) ⇒ StoreConfigDto
Returns a new instance of StoreConfigDto.
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 144 def initialize(country_code = nil, created_at = nil, fixed_rate = nil, store_id = 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, vertex = SKIP) @avalara = avalara unless avalara == SKIP @country_code = country_code @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 @store_id = store_id @tax_calculation_strategy = tax_calculation_strategy @tenant = tenant @updated_at = updated_at @updated_by = updated_by @version = version @vertex = vertex unless vertex == SKIP end |
Instance Attribute Details
#avalara ⇒ AvalaraConfigDto
Avalara configuration.
- Required if the
tax_calculation_strategyis set toavalara. - 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.
21 22 23 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 21 def avalara @avalara end |
#country_code ⇒ String
Avalara configuration.
- Required if the
tax_calculation_strategyis set toavalara. - 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.
31 32 33 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 31 def country_code @country_code end |
#created_at ⇒ DateTime
Creation date of the configuration.
35 36 37 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 35 def created_at @created_at end |
#custom ⇒ CustomConfigDto
Custom provider configuration.
- Required if the
tax_calculation_strategyis set tocustom. - If the tax calculation strategy is set to
custom, the given configuration will be used.
42 43 44 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 42 def custom @custom end |
#fixed_rate ⇒ FixedRateConfigDto
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.
53 54 55 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 53 def fixed_rate @fixed_rate end |
#fixed_rate_per_country ⇒ Hash[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.
66 67 68 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 66 def fixed_rate_per_country @fixed_rate_per_country end |
#is_deleted ⇒ TrueClass | FalseClass
Flag that indicates if the configuration was deleted.
70 71 72 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 70 def is_deleted @is_deleted end |
#store_id ⇒ String
Store identifier within the NewStore platform.
74 75 76 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 74 def store_id @store_id end |
#tax_calculation_strategy ⇒ TaxCalculationStrategyEnum
Store identifier within the NewStore platform.
78 79 80 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 78 def tax_calculation_strategy @tax_calculation_strategy end |
#tenant ⇒ String
Tenant identifier.
82 83 84 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 82 def tenant @tenant end |
#updated_at ⇒ DateTime
Latest update date of the configuration.
86 87 88 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 86 def updated_at @updated_at end |
#updated_by ⇒ String
Identifier of the user who updated the current version of the configuration.
91 92 93 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 91 def updated_by @updated_by end |
#version ⇒ Integer
Version number of the config.
- Version number 0 represents the system defaults.
96 97 98 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 96 def version @version end |
#vertex ⇒ VertexConfigDto
Vertex configuration.
- Required if the
tax_calculation_strategyis set tovertex. - 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.
106 107 108 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 106 def vertex @vertex end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 166 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. country_code = hash.key?('country_code') ? hash['country_code'] : nil 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'] store_id = hash.key?('store_id') ? hash['store_id'] : nil 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 vertex = VertexConfigDto.from_hash(hash['vertex']) if hash['vertex'] # Create object from extracted values. StoreConfigDto.new(country_code, created_at, fixed_rate, store_id, tax_calculation_strategy, tenant, updated_at, updated_by, version, avalara, custom, fixed_rate_per_country, is_deleted, vertex) end |
.names ⇒ Object
A mapping from model property names to API property names.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 109 def self.names @_hash = {} if @_hash.nil? @_hash['avalara'] = 'avalara' @_hash['country_code'] = 'country_code' @_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['store_id'] = 'store_id' @_hash['tax_calculation_strategy'] = 'tax_calculation_strategy' @_hash['tenant'] = 'tenant' @_hash['updated_at'] = 'updated_at' @_hash['updated_by'] = 'updated_by' @_hash['version'] = 'version' @_hash['vertex'] = 'vertex' @_hash end |
.nullables ⇒ Object
An array for nullable fields
140 141 142 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 140 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
129 130 131 132 133 134 135 136 137 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 129 def self.optionals %w[ avalara custom fixed_rate_per_country is_deleted vertex ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 220 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.country_code, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.created_at, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.fixed_rate, ->(val) { FixedRateConfigDto.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.store_id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.tax_calculation_strategy, ->(val) { TaxCalculationStrategyEnum.validate(val) }) and APIHelper.valid_type?(value.tenant, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.updated_at, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.updated_by, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.version, ->(val) { val.instance_of? Integer }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['country_code'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['created_at'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['fixed_rate'], ->(val) { FixedRateConfigDto.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['store_id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['tax_calculation_strategy'], ->(val) { TaxCalculationStrategyEnum.validate(val) }) and APIHelper.valid_type?(value['tenant'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['updated_at'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['updated_by'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['version'], ->(val) { val.instance_of? Integer }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
281 282 283 284 285 286 287 288 289 290 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 281 def inspect class_name = self.class.name.split('::').last "<#{class_name} avalara: #{@avalara.inspect}, country_code: #{@country_code.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}, store_id: #{@store_id.inspect},"\ " tax_calculation_strategy: #{@tax_calculation_strategy.inspect}, tenant:"\ " #{@tenant.inspect}, updated_at: #{@updated_at.inspect}, updated_by:"\ " #{@updated_by.inspect}, version: #{@version.inspect}, vertex: #{@vertex.inspect}>" end |
#to_custom_created_at ⇒ Object
210 211 212 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 210 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_updated_at ⇒ Object
214 215 216 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 214 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
271 272 273 274 275 276 277 278 |
# File 'lib/new_store_api/models/store_config_dto.rb', line 271 def to_s class_name = self.class.name.split('::').last "<#{class_name} avalara: #{@avalara}, country_code: #{@country_code}, created_at:"\ " #{@created_at}, custom: #{@custom}, fixed_rate: #{@fixed_rate}, fixed_rate_per_country:"\ " #{@fixed_rate_per_country}, is_deleted: #{@is_deleted}, store_id: #{@store_id},"\ " tax_calculation_strategy: #{@tax_calculation_strategy}, tenant: #{@tenant}, updated_at:"\ " #{@updated_at}, updated_by: #{@updated_by}, version: #{@version}, vertex: #{@vertex}>" end |