Class: NewStoreApi::TransactionTaxRateDto
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- NewStoreApi::TransactionTaxRateDto
- Defined in:
- lib/new_store_api/models/transaction_tax_rate_dto.rb
Overview
TransactionTaxRateDto Model.
Instance Attribute Summary collapse
-
#amount ⇒ Float
Monetary tax amount for the unit price corresponding to this tax_rate item's percent value, e.g.
-
#country_code ⇒ String
Country of jurisdiction for the applied tax.
-
#rate ⇒ Float
Tax percent value for this tax rate item, e.g.
-
#tax_name ⇒ String
Name of the applied tax.
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(amount = nil, country_code = nil, rate = nil, tax_name = nil) ⇒ TransactionTaxRateDto
constructor
A new instance of TransactionTaxRateDto.
-
#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(amount = nil, country_code = nil, rate = nil, tax_name = nil) ⇒ TransactionTaxRateDto
Returns a new instance of TransactionTaxRateDto.
49 50 51 52 53 54 |
# File 'lib/new_store_api/models/transaction_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
#amount ⇒ Float
Monetary tax amount for the unit price corresponding to this tax_rate item's percent value, e.g. 3.37.
15 16 17 |
# File 'lib/new_store_api/models/transaction_tax_rate_dto.rb', line 15 def amount @amount end |
#country_code ⇒ String
Country of jurisdiction for the applied tax.
19 20 21 |
# File 'lib/new_store_api/models/transaction_tax_rate_dto.rb', line 19 def country_code @country_code end |
#rate ⇒ Float
Tax percent value for this tax rate item, e.g. 0.19 means 19% tax.
23 24 25 |
# File 'lib/new_store_api/models/transaction_tax_rate_dto.rb', line 23 def rate @rate end |
#tax_name ⇒ String
Name of the applied tax.
27 28 29 |
# File 'lib/new_store_api/models/transaction_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/transaction_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. TransactionTaxRateDto.new(amount, country_code, rate, tax_name) end |
.names ⇒ Object
A mapping from model property names to API property names.
30 31 32 33 34 35 36 37 |
# File 'lib/new_store_api/models/transaction_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 |
.nullables ⇒ Object
An array for nullable fields
45 46 47 |
# File 'lib/new_store_api/models/transaction_tax_rate_dto.rb', line 45 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
40 41 42 |
# File 'lib/new_store_api/models/transaction_tax_rate_dto.rb', line 40 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
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/transaction_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? Float }) 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? Float }) 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
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
111 112 113 114 115 |
# File 'lib/new_store_api/models/transaction_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_s ⇒ Object
Provides a human-readable string representation of the object.
104 105 106 107 108 |
# File 'lib/new_store_api/models/transaction_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 |