Class: NewStoreApi::QuotationTaxRateDto

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

Overview

QuotationTaxRateDto 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(amount = nil, country_code = nil, rate = nil, tax_name = nil) ⇒ QuotationTaxRateDto

Returns a new instance of QuotationTaxRateDto.



49
50
51
52
53
54
# File 'lib/new_store_api/models/quotation_tax_rate_dto.rb', line 49

def initialize(amount = nil, country_code = nil, rate = nil, tax_name = nil)
  @amount = amount
  @country_code = country_code
  @rate = rate
  @tax_name = tax_name
end

Instance Attribute Details

#amountInteger

Monetary tax amount for the unit price corresponding to this tax_rate item's percent value, in the currency's minor unit.

Returns:

  • (Integer)


15
16
17
# File 'lib/new_store_api/models/quotation_tax_rate_dto.rb', line 15

def amount
  @amount
end

#country_codeString

Country of jurisdiction for the applied tax.

Returns:

  • (String)


19
20
21
# File 'lib/new_store_api/models/quotation_tax_rate_dto.rb', line 19

def country_code
  @country_code
end

#rateFloat

Tax percent value for this tax rate item, e.g. 0.19 means 19% tax.

Returns:

  • (Float)


23
24
25
# File 'lib/new_store_api/models/quotation_tax_rate_dto.rb', line 23

def rate
  @rate
end

#tax_nameString

Name of the applied tax.

Returns:

  • (String)


27
28
29
# File 'lib/new_store_api/models/quotation_tax_rate_dto.rb', line 27

def tax_name
  @tax_name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/new_store_api/models/quotation_tax_rate_dto.rb', line 57

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  amount = hash.key?('amount') ? hash['amount'] : nil
  country_code = hash.key?('country_code') ? hash['country_code'] : nil
  rate = hash.key?('rate') ? hash['rate'] : nil
  tax_name = hash.key?('tax_name') ? hash['tax_name'] : nil

  # Create object from extracted values.
  QuotationTaxRateDto.new(amount,
                          country_code,
                          rate,
                          tax_name)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
# File 'lib/new_store_api/models/quotation_tax_rate_dto.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['amount'] = 'amount'
  @_hash['country_code'] = 'country_code'
  @_hash['rate'] = 'rate'
  @_hash['tax_name'] = 'tax_name'
  @_hash
end

.nullablesObject

An array for nullable fields



45
46
47
# File 'lib/new_store_api/models/quotation_tax_rate_dto.rb', line 45

def self.nullables
  []
end

.optionalsObject

An array for optional fields



40
41
42
# File 'lib/new_store_api/models/quotation_tax_rate_dto.rb', line 40

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/new_store_api/models/quotation_tax_rate_dto.rb', line 75

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.amount,
                            ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.country_code,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.rate,
                              ->(val) { val.instance_of? Float }) and
        APIHelper.valid_type?(value.tax_name,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['amount'],
                          ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['country_code'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['rate'],
                            ->(val) { val.instance_of? Float }) and
      APIHelper.valid_type?(value['tax_name'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



111
112
113
114
115
# File 'lib/new_store_api/models/quotation_tax_rate_dto.rb', line 111

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount.inspect}, country_code: #{@country_code.inspect}, rate:"\
  " #{@rate.inspect}, tax_name: #{@tax_name.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



104
105
106
107
108
# File 'lib/new_store_api/models/quotation_tax_rate_dto.rb', line 104

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount}, country_code: #{@country_code}, rate: #{@rate},"\
  " tax_name: #{@tax_name}>"
end