Class: NewStoreApi::CustomConfigDto
- Defined in:
- lib/new_store_api/models/custom_config_dto.rb
Overview
CustomConfigDto Model.
Instance Attribute Summary collapse
-
#additional_config ⇒ CustomConfigAdditionalDto
Other necessary configuration specific to the custom provider (currently configs for non-officially supported avalara based custom implementation).
-
#api_version ⇒ CustomApiVersionEnum
Other necessary configuration specific to the custom provider (currently configs for non-officially supported avalara based custom implementation).
-
#authentication ⇒ CustomConfigAuthenticationDto
Custom provider API authentication method.
-
#base_url ⇒ String
The base URL for the custom taxes RESTful API.
-
#exemption_classes ⇒ Array[ExemptionClassItemDto]
A list of supported exemption classes.
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(api_version = nil, additional_config = SKIP, authentication = SKIP, base_url = SKIP, exemption_classes = SKIP) ⇒ CustomConfigDto
constructor
A new instance of CustomConfigDto.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#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(api_version = nil, additional_config = SKIP, authentication = SKIP, base_url = SKIP, exemption_classes = SKIP) ⇒ CustomConfigDto
Returns a new instance of CustomConfigDto.
67 68 69 70 71 72 73 74 75 |
# File 'lib/new_store_api/models/custom_config_dto.rb', line 67 def initialize(api_version = nil, additional_config = SKIP, authentication = SKIP, base_url = SKIP, exemption_classes = SKIP) @additional_config = additional_config unless additional_config == SKIP @api_version = api_version @authentication = authentication unless authentication == SKIP @base_url = base_url unless base_url == SKIP @exemption_classes = exemption_classes unless exemption_classes == SKIP end |
Instance Attribute Details
#additional_config ⇒ CustomConfigAdditionalDto
Other necessary configuration specific to the custom provider (currently configs for non-officially supported avalara based custom implementation)
15 16 17 |
# File 'lib/new_store_api/models/custom_config_dto.rb', line 15 def additional_config @additional_config end |
#api_version ⇒ CustomApiVersionEnum
Other necessary configuration specific to the custom provider (currently configs for non-officially supported avalara based custom implementation)
20 21 22 |
# File 'lib/new_store_api/models/custom_config_dto.rb', line 20 def api_version @api_version end |
#authentication ⇒ CustomConfigAuthenticationDto
Custom provider API authentication method.
- Currently, only Basic authentication is supported.
- If the tax calculation strategy is set to
customandapi_versionis set tov1, the given configuration will be used.
27 28 29 |
# File 'lib/new_store_api/models/custom_config_dto.rb', line 27 def authentication @authentication end |
#base_url ⇒ String
The base URL for the custom taxes RESTful API. The value should include the route prefix to the quotation API.
- Required if the
api_versionis set tov1. - If the tax calculation strategy is set to
customandapi_versionis set tov1, the given configuration will be used.
35 36 37 |
# File 'lib/new_store_api/models/custom_config_dto.rb', line 35 def base_url @base_url end |
#exemption_classes ⇒ Array[ExemptionClassItemDto]
A list of supported exemption classes.
39 40 41 |
# File 'lib/new_store_api/models/custom_config_dto.rb', line 39 def exemption_classes @exemption_classes end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/new_store_api/models/custom_config_dto.rb', line 78 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. api_version = hash.key?('api_version') ? hash['api_version'] : nil additional_config = CustomConfigAdditionalDto.from_hash(hash['additional_config']) if hash['additional_config'] authentication = CustomConfigAuthenticationDto.from_hash(hash['authentication']) if hash['authentication'] base_url = hash.key?('base_url') ? hash['base_url'] : SKIP # Parameter is an array, so we need to iterate through it exemption_classes = nil unless hash['exemption_classes'].nil? exemption_classes = [] hash['exemption_classes'].each do |structure| exemption_classes << (ExemptionClassItemDto.from_hash(structure) if structure) end end exemption_classes = SKIP unless hash.key?('exemption_classes') # Create object from extracted values. CustomConfigDto.new(api_version, additional_config, authentication, base_url, exemption_classes) end |
.names ⇒ Object
A mapping from model property names to API property names.
42 43 44 45 46 47 48 49 50 |
# File 'lib/new_store_api/models/custom_config_dto.rb', line 42 def self.names @_hash = {} if @_hash.nil? @_hash['additional_config'] = 'additional_config' @_hash['api_version'] = 'api_version' @_hash['authentication'] = 'authentication' @_hash['base_url'] = 'base_url' @_hash['exemption_classes'] = 'exemption_classes' @_hash end |
.nullables ⇒ Object
An array for nullable fields
63 64 65 |
# File 'lib/new_store_api/models/custom_config_dto.rb', line 63 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
53 54 55 56 57 58 59 60 |
# File 'lib/new_store_api/models/custom_config_dto.rb', line 53 def self.optionals %w[ additional_config authentication base_url exemption_classes ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/new_store_api/models/custom_config_dto.rb', line 109 def self.validate(value) if value.instance_of? self return APIHelper.valid_type?(value.api_version, ->(val) { CustomApiVersionEnum.validate(val) }) end return false unless value.instance_of? Hash APIHelper.valid_type?(value['api_version'], ->(val) { CustomApiVersionEnum.validate(val) }) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
130 131 132 133 134 135 |
# File 'lib/new_store_api/models/custom_config_dto.rb', line 130 def inspect class_name = self.class.name.split('::').last "<#{class_name} additional_config: #{@additional_config.inspect}, api_version:"\ " #{@api_version.inspect}, authentication: #{@authentication.inspect}, base_url:"\ " #{@base_url.inspect}, exemption_classes: #{@exemption_classes.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
122 123 124 125 126 127 |
# File 'lib/new_store_api/models/custom_config_dto.rb', line 122 def to_s class_name = self.class.name.split('::').last "<#{class_name} additional_config: #{@additional_config}, api_version: #{@api_version},"\ " authentication: #{@authentication}, base_url: #{@base_url}, exemption_classes:"\ " #{@exemption_classes}>" end |