Class: NewStoreApi::QuotationResultDto
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- NewStoreApi::QuotationResultDto
- Defined in:
- lib/new_store_api/models/quotation_result_dto.rb
Overview
QuotationResultDto Model.
Instance Attribute Summary collapse
-
#calculation_mode ⇒ CalculationModeEnum
TODO: Write general description for this method.
-
#exemption_class ⇒ ExemptionClassEnum
TODO: Write general description for this method.
-
#exemption_number ⇒ String
The number of the customer's exemption certificate.
-
#fallback_error ⇒ FallbackErrorDto
The optional error of the original tax provider execution that triggered the execution of the fall-back tax provider.
-
#items ⇒ Array[EnrichedQuotationItemDto]
A list of the items sold/returned in the quotation, enriched with the tax amounts.
-
#tax_exempt ⇒ TrueClass | FalseClass
Defines the tax exemption status of the transaction.
-
#totals ⇒ QuotationTotalsDto
The transaction total amounts, in the currency's minor unit.
-
#transaction_type ⇒ TransactionTypeEnum
The transaction total amounts, in the currency's minor unit.
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.
Instance Method Summary collapse
-
#initialize(items = nil, totals = nil, calculation_mode = SKIP, exemption_class = SKIP, exemption_number = SKIP, fallback_error = SKIP, tax_exempt = false, transaction_type = SKIP) ⇒ QuotationResultDto
constructor
A new instance of QuotationResultDto.
-
#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(items = nil, totals = nil, calculation_mode = SKIP, exemption_class = SKIP, exemption_number = SKIP, fallback_error = SKIP, tax_exempt = false, transaction_type = SKIP) ⇒ QuotationResultDto
Returns a new instance of QuotationResultDto.
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/new_store_api/models/quotation_result_dto.rb', line 80 def initialize(items = nil, totals = nil, calculation_mode = SKIP, exemption_class = SKIP, exemption_number = SKIP, fallback_error = SKIP, tax_exempt = false, transaction_type = SKIP) @calculation_mode = calculation_mode unless calculation_mode == SKIP @exemption_class = exemption_class unless exemption_class == SKIP @exemption_number = exemption_number unless exemption_number == SKIP @fallback_error = fallback_error unless fallback_error == SKIP @items = items @tax_exempt = tax_exempt unless tax_exempt == SKIP @totals = totals @transaction_type = transaction_type unless transaction_type == SKIP end |
Instance Attribute Details
#calculation_mode ⇒ CalculationModeEnum
TODO: Write general description for this method
14 15 16 |
# File 'lib/new_store_api/models/quotation_result_dto.rb', line 14 def calculation_mode @calculation_mode end |
#exemption_class ⇒ ExemptionClassEnum
TODO: Write general description for this method
18 19 20 |
# File 'lib/new_store_api/models/quotation_result_dto.rb', line 18 def exemption_class @exemption_class end |
#exemption_number ⇒ String
The number of the customer's exemption certificate.
- The given value can be verified by the auditors in the event of a tax audit.
24 25 26 |
# File 'lib/new_store_api/models/quotation_result_dto.rb', line 24 def exemption_number @exemption_number end |
#fallback_error ⇒ FallbackErrorDto
The optional error of the original tax provider execution that triggered the execution of the fall-back tax provider. Will be returned when the orignal tax provider failure occurs.
30 31 32 |
# File 'lib/new_store_api/models/quotation_result_dto.rb', line 30 def fallback_error @fallback_error end |
#items ⇒ Array[EnrichedQuotationItemDto]
A list of the items sold/returned in the quotation, enriched with the tax amounts. Monetary fields are in the currency's minor unit.
35 36 37 |
# File 'lib/new_store_api/models/quotation_result_dto.rb', line 35 def items @items end |
#tax_exempt ⇒ TrueClass | FalseClass
Defines the tax exemption status of the transaction.
39 40 41 |
# File 'lib/new_store_api/models/quotation_result_dto.rb', line 39 def tax_exempt @tax_exempt end |
#totals ⇒ QuotationTotalsDto
The transaction total amounts, in the currency's minor unit.
43 44 45 |
# File 'lib/new_store_api/models/quotation_result_dto.rb', line 43 def totals @totals end |
#transaction_type ⇒ TransactionTypeEnum
The transaction total amounts, in the currency's minor unit.
47 48 49 |
# File 'lib/new_store_api/models/quotation_result_dto.rb', line 47 def transaction_type @transaction_type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/new_store_api/models/quotation_result_dto.rb', line 95 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # Parameter is an array, so we need to iterate through it items = nil unless hash['items'].nil? items = [] hash['items'].each do |structure| items << (EnrichedQuotationItemDto.from_hash(structure) if structure) end end items = nil unless hash.key?('items') totals = QuotationTotalsDto.from_hash(hash['totals']) if hash['totals'] calculation_mode = hash.key?('calculation_mode') ? hash['calculation_mode'] : SKIP exemption_class = hash.key?('exemption_class') ? hash['exemption_class'] : SKIP exemption_number = hash.key?('exemption_number') ? hash['exemption_number'] : SKIP fallback_error = FallbackErrorDto.from_hash(hash['fallback_error']) if hash['fallback_error'] tax_exempt = hash['tax_exempt'] ||= false transaction_type = hash.key?('transaction_type') ? hash['transaction_type'] : SKIP # Create object from extracted values. QuotationResultDto.new(items, totals, calculation_mode, exemption_class, exemption_number, fallback_error, tax_exempt, transaction_type) end |
.names ⇒ Object
A mapping from model property names to API property names.
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/new_store_api/models/quotation_result_dto.rb', line 50 def self.names @_hash = {} if @_hash.nil? @_hash['calculation_mode'] = 'calculation_mode' @_hash['exemption_class'] = 'exemption_class' @_hash['exemption_number'] = 'exemption_number' @_hash['fallback_error'] = 'fallback_error' @_hash['items'] = 'items' @_hash['tax_exempt'] = 'tax_exempt' @_hash['totals'] = 'totals' @_hash['transaction_type'] = 'transaction_type' @_hash end |
.nullables ⇒ Object
An array for nullable fields
76 77 78 |
# File 'lib/new_store_api/models/quotation_result_dto.rb', line 76 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/new_store_api/models/quotation_result_dto.rb', line 64 def self.optionals %w[ calculation_mode exemption_class exemption_number fallback_error tax_exempt transaction_type ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
143 144 145 146 147 148 149 150 |
# File 'lib/new_store_api/models/quotation_result_dto.rb', line 143 def inspect class_name = self.class.name.split('::').last "<#{class_name} calculation_mode: #{@calculation_mode.inspect}, exemption_class:"\ " #{@exemption_class.inspect}, exemption_number: #{@exemption_number.inspect},"\ " fallback_error: #{@fallback_error.inspect}, items: #{@items.inspect}, tax_exempt:"\ " #{@tax_exempt.inspect}, totals: #{@totals.inspect}, transaction_type:"\ " #{@transaction_type.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
134 135 136 137 138 139 140 |
# File 'lib/new_store_api/models/quotation_result_dto.rb', line 134 def to_s class_name = self.class.name.split('::').last "<#{class_name} calculation_mode: #{@calculation_mode}, exemption_class:"\ " #{@exemption_class}, exemption_number: #{@exemption_number}, fallback_error:"\ " #{@fallback_error}, items: #{@items}, tax_exempt: #{@tax_exempt}, totals: #{@totals},"\ " transaction_type: #{@transaction_type}>" end |