Class: NewStoreApi::SalesOrderPrice1
- Defined in:
- lib/new_store_api/models/sales_order_price1.rb
Overview
The response for retrieving price information.
Instance Attribute Summary collapse
-
#base ⇒ Float
Price of the item that contains the catalog price or the overridden price.
-
#discount ⇒ Float
The applied discount to the item.
-
#gross ⇒ Float
The gross price of the item.
-
#net ⇒ Float
The net price of the item.
-
#tax ⇒ Float
The taxes of the item.
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(base = nil, discount = nil, gross = nil, net = nil, tax = nil) ⇒ SalesOrderPrice1
constructor
A new instance of SalesOrderPrice1.
-
#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(base = nil, discount = nil, gross = nil, net = nil, tax = nil) ⇒ SalesOrderPrice1
Returns a new instance of SalesOrderPrice1.
53 54 55 56 57 58 59 60 |
# File 'lib/new_store_api/models/sales_order_price1.rb', line 53 def initialize(base = nil, discount = nil, gross = nil, net = nil, tax = nil) @base = base @discount = discount @gross = gross @net = net @tax = tax end |
Instance Attribute Details
#base ⇒ Float
Price of the item that contains the catalog price or the overridden price.
14 15 16 |
# File 'lib/new_store_api/models/sales_order_price1.rb', line 14 def base @base end |
#discount ⇒ Float
The applied discount to the item.
18 19 20 |
# File 'lib/new_store_api/models/sales_order_price1.rb', line 18 def discount @discount end |
#gross ⇒ Float
The gross price of the item.
22 23 24 |
# File 'lib/new_store_api/models/sales_order_price1.rb', line 22 def gross @gross end |
#net ⇒ Float
The net price of the item.
26 27 28 |
# File 'lib/new_store_api/models/sales_order_price1.rb', line 26 def net @net end |
#tax ⇒ Float
The taxes of the item.
30 31 32 |
# File 'lib/new_store_api/models/sales_order_price1.rb', line 30 def tax @tax end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/new_store_api/models/sales_order_price1.rb', line 63 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. base = hash.key?('base') ? hash['base'] : nil discount = hash.key?('discount') ? hash['discount'] : nil gross = hash.key?('gross') ? hash['gross'] : nil net = hash.key?('net') ? hash['net'] : nil tax = hash.key?('tax') ? hash['tax'] : nil # Create object from extracted values. SalesOrderPrice1.new(base, discount, gross, net, tax) end |
.names ⇒ Object
A mapping from model property names to API property names.
33 34 35 36 37 38 39 40 41 |
# File 'lib/new_store_api/models/sales_order_price1.rb', line 33 def self.names @_hash = {} if @_hash.nil? @_hash['base'] = 'base' @_hash['discount'] = 'discount' @_hash['gross'] = 'gross' @_hash['net'] = 'net' @_hash['tax'] = 'tax' @_hash end |
.nullables ⇒ Object
An array for nullable fields
49 50 51 |
# File 'lib/new_store_api/models/sales_order_price1.rb', line 49 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
44 45 46 |
# File 'lib/new_store_api/models/sales_order_price1.rb', line 44 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/new_store_api/models/sales_order_price1.rb', line 83 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.base, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.discount, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.gross, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.net, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.tax, ->(val) { val.instance_of? Float }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['base'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['discount'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['gross'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['net'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['tax'], ->(val) { val.instance_of? Float }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
123 124 125 126 127 |
# File 'lib/new_store_api/models/sales_order_price1.rb', line 123 def inspect class_name = self.class.name.split('::').last "<#{class_name} base: #{@base.inspect}, discount: #{@discount.inspect}, gross:"\ " #{@gross.inspect}, net: #{@net.inspect}, tax: #{@tax.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
116 117 118 119 120 |
# File 'lib/new_store_api/models/sales_order_price1.rb', line 116 def to_s class_name = self.class.name.split('::').last "<#{class_name} base: #{@base}, discount: #{@discount}, gross: #{@gross}, net: #{@net},"\ " tax: #{@tax}>" end |