Class: NewStoreApi::FixedRateConfigCreateDto
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- NewStoreApi::FixedRateConfigCreateDto
- Defined in:
- lib/new_store_api/models/fixed_rate_config_create_dto.rb
Overview
FixedRateConfigCreateDto Model.
Instance Attribute Summary collapse
-
#exemption_classes ⇒ Array[ExemptionClassItemCreateDto]
A list of supported exemption classes.
-
#tax_name ⇒ String
Tax name to be used in the tax lines.
-
#tax_rate ⇒ Float
Tax rate to be used as a fixed rate during tax calculations.
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(tax_rate = nil, exemption_classes = SKIP, tax_name = SKIP) ⇒ FixedRateConfigCreateDto
constructor
A new instance of FixedRateConfigCreateDto.
-
#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(tax_rate = nil, exemption_classes = SKIP, tax_name = SKIP) ⇒ FixedRateConfigCreateDto
Returns a new instance of FixedRateConfigCreateDto.
47 48 49 50 51 |
# File 'lib/new_store_api/models/fixed_rate_config_create_dto.rb', line 47 def initialize(tax_rate = nil, exemption_classes = SKIP, tax_name = SKIP) @exemption_classes = exemption_classes unless exemption_classes == SKIP @tax_name = tax_name unless tax_name == SKIP @tax_rate = tax_rate end |
Instance Attribute Details
#exemption_classes ⇒ Array[ExemptionClassItemCreateDto]
A list of supported exemption classes.
14 15 16 |
# File 'lib/new_store_api/models/fixed_rate_config_create_dto.rb', line 14 def exemption_classes @exemption_classes end |
#tax_name ⇒ String
Tax name to be used in the tax lines.
18 19 20 |
# File 'lib/new_store_api/models/fixed_rate_config_create_dto.rb', line 18 def tax_name @tax_name end |
#tax_rate ⇒ Float
Tax rate to be used as a fixed rate during tax calculations.
- Allows up to 5 decimal points.
23 24 25 |
# File 'lib/new_store_api/models/fixed_rate_config_create_dto.rb', line 23 def tax_rate @tax_rate end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/new_store_api/models/fixed_rate_config_create_dto.rb', line 54 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. tax_rate = hash.key?('tax_rate') ? hash['tax_rate'] : nil # 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 << (ExemptionClassItemCreateDto.from_hash(structure) if structure) end end exemption_classes = SKIP unless hash.key?('exemption_classes') tax_name = hash.key?('tax_name') ? hash['tax_name'] : SKIP # Create object from extracted values. FixedRateConfigCreateDto.new(tax_rate, exemption_classes, tax_name) end |
.names ⇒ Object
A mapping from model property names to API property names.
26 27 28 29 30 31 32 |
# File 'lib/new_store_api/models/fixed_rate_config_create_dto.rb', line 26 def self.names @_hash = {} if @_hash.nil? @_hash['exemption_classes'] = 'exemption_classes' @_hash['tax_name'] = 'tax_name' @_hash['tax_rate'] = 'tax_rate' @_hash end |
.nullables ⇒ Object
An array for nullable fields
43 44 45 |
# File 'lib/new_store_api/models/fixed_rate_config_create_dto.rb', line 43 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
35 36 37 38 39 40 |
# File 'lib/new_store_api/models/fixed_rate_config_create_dto.rb', line 35 def self.optionals %w[ exemption_classes tax_name ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/new_store_api/models/fixed_rate_config_create_dto.rb', line 79 def self.validate(value) if value.instance_of? self return APIHelper.valid_type?(value.tax_rate, ->(val) { val.instance_of? Float }) end return false unless value.instance_of? Hash APIHelper.valid_type?(value['tax_rate'], ->(val) { val.instance_of? Float }) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
99 100 101 102 103 |
# File 'lib/new_store_api/models/fixed_rate_config_create_dto.rb', line 99 def inspect class_name = self.class.name.split('::').last "<#{class_name} exemption_classes: #{@exemption_classes.inspect}, tax_name:"\ " #{@tax_name.inspect}, tax_rate: #{@tax_rate.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
92 93 94 95 96 |
# File 'lib/new_store_api/models/fixed_rate_config_create_dto.rb', line 92 def to_s class_name = self.class.name.split('::').last "<#{class_name} exemption_classes: #{@exemption_classes}, tax_name: #{@tax_name}, tax_rate:"\ " #{@tax_rate}>" end |