Class: NewStoreApi::SalesOrderTaxLine
- Defined in:
- lib/new_store_api/models/sales_order_tax_line.rb
Overview
SalesOrderTaxLine Model.
Instance Attribute Summary collapse
-
#amount ⇒ Float
Monetary tax amount for this line.
-
#country_code ⇒ String
The code of the country of the tax in the ISO 3166 ALPHA-2 format.
-
#name ⇒ String
Name of the tax line, e.g.
-
#rate ⇒ Float
Decimal representation of the tax rate for this line, e.g.
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(amount = nil, rate = nil, country_code = SKIP, name = SKIP) ⇒ SalesOrderTaxLine
constructor
A new instance of SalesOrderTaxLine.
-
#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, rate = nil, country_code = SKIP, name = SKIP) ⇒ SalesOrderTaxLine
Returns a new instance of SalesOrderTaxLine.
52 53 54 55 56 57 |
# File 'lib/new_store_api/models/sales_order_tax_line.rb', line 52 def initialize(amount = nil, rate = nil, country_code = SKIP, name = SKIP) @amount = amount @country_code = country_code unless country_code == SKIP @name = name unless name == SKIP @rate = rate end |
Instance Attribute Details
#amount ⇒ Float
Monetary tax amount for this line.
14 15 16 |
# File 'lib/new_store_api/models/sales_order_tax_line.rb', line 14 def amount @amount end |
#country_code ⇒ String
The code of the country of the tax in the ISO 3166 ALPHA-2 format. For example, GB, DE or US.
19 20 21 |
# File 'lib/new_store_api/models/sales_order_tax_line.rb', line 19 def country_code @country_code end |
#name ⇒ String
Name of the tax line, e.g. MA Sales Tax.
23 24 25 |
# File 'lib/new_store_api/models/sales_order_tax_line.rb', line 23 def name @name end |
#rate ⇒ Float
Decimal representation of the tax rate for this line, e.g. 6.25
27 28 29 |
# File 'lib/new_store_api/models/sales_order_tax_line.rb', line 27 def rate @rate end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/new_store_api/models/sales_order_tax_line.rb', line 60 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. amount = hash.key?('amount') ? hash['amount'] : nil rate = hash.key?('rate') ? hash['rate'] : nil country_code = hash.key?('country_code') ? hash['country_code'] : SKIP name = hash.key?('name') ? hash['name'] : SKIP # Create object from extracted values. SalesOrderTaxLine.new(amount, rate, country_code, 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/sales_order_tax_line.rb', line 30 def self.names @_hash = {} if @_hash.nil? @_hash['amount'] = 'amount' @_hash['country_code'] = 'country_code' @_hash['name'] = 'name' @_hash['rate'] = 'rate' @_hash end |
.nullables ⇒ Object
An array for nullable fields
48 49 50 |
# File 'lib/new_store_api/models/sales_order_tax_line.rb', line 48 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
40 41 42 43 44 45 |
# File 'lib/new_store_api/models/sales_order_tax_line.rb', line 40 def self.optionals %w[ country_code name ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
84 85 86 87 88 |
# File 'lib/new_store_api/models/sales_order_tax_line.rb', line 84 def inspect class_name = self.class.name.split('::').last "<#{class_name} amount: #{@amount.inspect}, country_code: #{@country_code.inspect}, name:"\ " #{@name.inspect}, rate: #{@rate.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
77 78 79 80 81 |
# File 'lib/new_store_api/models/sales_order_tax_line.rb', line 77 def to_s class_name = self.class.name.split('::').last "<#{class_name} amount: #{@amount}, country_code: #{@country_code}, name: #{@name}, rate:"\ " #{@rate}>" end |