Class: NewStoreApi::InjectedOrderItemTaxLine
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- NewStoreApi::InjectedOrderItemTaxLine
- Defined in:
- lib/new_store_api/models/injected_order_item_tax_line.rb
Overview
InjectedOrderItemTaxLine Model.
Instance Attribute Summary collapse
-
#amount ⇒ Float
The tax amount.
-
#country_code ⇒ String
The code of the country of the tax in the ISO 3166 ALPHA-2 format.
-
#name ⇒ String
A description of the tax type.
-
#rate ⇒ Float
The tax rate.
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, name = nil, rate = nil, country_code = SKIP) ⇒ InjectedOrderItemTaxLine
constructor
A new instance of InjectedOrderItemTaxLine.
-
#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, name = nil, rate = nil, country_code = SKIP) ⇒ InjectedOrderItemTaxLine
Returns a new instance of InjectedOrderItemTaxLine.
51 52 53 54 55 56 |
# File 'lib/new_store_api/models/injected_order_item_tax_line.rb', line 51 def initialize(amount = nil, name = nil, rate = nil, country_code = SKIP) @amount = amount @country_code = country_code unless country_code == SKIP @name = name @rate = rate end |
Instance Attribute Details
#amount ⇒ Float
The tax amount.
14 15 16 |
# File 'lib/new_store_api/models/injected_order_item_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/injected_order_item_tax_line.rb', line 19 def country_code @country_code end |
#name ⇒ String
A description of the tax type. Required.
23 24 25 |
# File 'lib/new_store_api/models/injected_order_item_tax_line.rb', line 23 def name @name end |
#rate ⇒ Float
The tax rate. Must be in form of ratio between 0 and 1, not percentage.
27 28 29 |
# File 'lib/new_store_api/models/injected_order_item_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.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/new_store_api/models/injected_order_item_tax_line.rb', line 59 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. amount = hash.key?('amount') ? hash['amount'] : nil name = hash.key?('name') ? hash['name'] : nil rate = hash.key?('rate') ? hash['rate'] : nil country_code = hash.key?('country_code') ? hash['country_code'] : SKIP # Create object from extracted values. InjectedOrderItemTaxLine.new(amount, name, rate, country_code) 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/injected_order_item_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
47 48 49 |
# File 'lib/new_store_api/models/injected_order_item_tax_line.rb', line 47 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
40 41 42 43 44 |
# File 'lib/new_store_api/models/injected_order_item_tax_line.rb', line 40 def self.optionals %w[ country_code ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/new_store_api/models/injected_order_item_tax_line.rb', line 77 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.name, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.rate, ->(val) { val.instance_of? Float }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['amount'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['name'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['rate'], ->(val) { val.instance_of? Float }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
109 110 111 112 113 |
# File 'lib/new_store_api/models/injected_order_item_tax_line.rb', line 109 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.
102 103 104 105 106 |
# File 'lib/new_store_api/models/injected_order_item_tax_line.rb', line 102 def to_s class_name = self.class.name.split('::').last "<#{class_name} amount: #{@amount}, country_code: #{@country_code}, name: #{@name}, rate:"\ " #{@rate}>" end |