Class: NewStoreApi::TaxRateDto

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

Overview

TaxRateDto 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, exempt_amount = SKIP, tax_status = SKIP, taxable_amount = SKIP) ⇒ TaxRateDto

Returns a new instance of TaxRateDto.



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/new_store_api/models/tax_rate_dto.rb', line 68

def initialize(amount = nil, country_code = nil, rate = nil, tax_name = nil,
               exempt_amount = SKIP, tax_status = SKIP,
               taxable_amount = SKIP)
  @amount = amount
  @country_code = country_code
  @exempt_amount = exempt_amount unless exempt_amount == SKIP
  @rate = rate
  @tax_name = tax_name
  @tax_status = tax_status unless tax_status == SKIP
  @taxable_amount = taxable_amount unless taxable_amount == SKIP
end

Instance Attribute Details

#amountFloat

Monetary tax amount for the unit price corresponding to this tax_rate item's percent value, e.g. 3.37.

Returns:

  • (Float)


15
16
17
# File 'lib/new_store_api/models/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/tax_rate_dto.rb', line 19

def country_code
  @country_code
end

#exempt_amountFloat

The item net amount which has been tax exempt.

Returns:

  • (Float)


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

def exempt_amount
  @exempt_amount
end

#rateFloat

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

Returns:

  • (Float)


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

def rate
  @rate
end

#tax_nameString

Name of the applied tax.

Returns:

  • (String)


31
32
33
# File 'lib/new_store_api/models/tax_rate_dto.rb', line 31

def tax_name
  @tax_name
end

#tax_statusTaxStatusEnum

Name of the applied tax.

Returns:



35
36
37
# File 'lib/new_store_api/models/tax_rate_dto.rb', line 35

def tax_status
  @tax_status
end

#taxable_amountFloat

The taxable item net amount on which the tax is chargeable.

Returns:

  • (Float)


39
40
41
# File 'lib/new_store_api/models/tax_rate_dto.rb', line 39

def taxable_amount
  @taxable_amount
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/new_store_api/models/tax_rate_dto.rb', line 81

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
  exempt_amount = hash.key?('exempt_amount') ? hash['exempt_amount'] : SKIP
  tax_status = hash.key?('tax_status') ? hash['tax_status'] : SKIP
  taxable_amount =
    hash.key?('taxable_amount') ? hash['taxable_amount'] : SKIP

  # Create object from extracted values.
  TaxRateDto.new(amount,
                 country_code,
                 rate,
                 tax_name,
                 exempt_amount,
                 tax_status,
                 taxable_amount)
end

.namesObject

A mapping from model property names to API property names.



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/new_store_api/models/tax_rate_dto.rb', line 42

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

.nullablesObject

An array for nullable fields



64
65
66
# File 'lib/new_store_api/models/tax_rate_dto.rb', line 64

def self.nullables
  []
end

.optionalsObject

An array for optional fields



55
56
57
58
59
60
61
# File 'lib/new_store_api/models/tax_rate_dto.rb', line 55

def self.optionals
  %w[
    exempt_amount
    tax_status
    taxable_amount
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



113
114
115
116
117
118
119
# File 'lib/new_store_api/models/tax_rate_dto.rb', line 113

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

#to_sObject

Provides a human-readable string representation of the object.



105
106
107
108
109
110
# File 'lib/new_store_api/models/tax_rate_dto.rb', line 105

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