Class: NewStoreApi::SalesOrderItemShipment
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- NewStoreApi::SalesOrderItemShipment
- Defined in:
- lib/new_store_api/models/sales_order_item_shipment.rb
Overview
SalesOrderItemShipment Model.
Instance Attribute Summary collapse
-
#discounts ⇒ Array[SalesOrderDiscount]
A list of applied discounts.
-
#id ⇒ String
Order item UUID of the shipment.
-
#price ⇒ SalesOrderPrice1
The response for retrieving price information.
-
#tax_lines ⇒ Array[SalesOrderTaxLine]
Detailed tax information.
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(id = nil, price = nil, discounts = SKIP, tax_lines = SKIP) ⇒ SalesOrderItemShipment
constructor
A new instance of SalesOrderItemShipment.
-
#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(id = nil, price = nil, discounts = SKIP, tax_lines = SKIP) ⇒ SalesOrderItemShipment
Returns a new instance of SalesOrderItemShipment.
51 52 53 54 55 56 |
# File 'lib/new_store_api/models/sales_order_item_shipment.rb', line 51 def initialize(id = nil, price = nil, discounts = SKIP, tax_lines = SKIP) @discounts = discounts unless discounts == SKIP @id = id @price = price @tax_lines = tax_lines unless tax_lines == SKIP end |
Instance Attribute Details
#discounts ⇒ Array[SalesOrderDiscount]
A list of applied discounts
14 15 16 |
# File 'lib/new_store_api/models/sales_order_item_shipment.rb', line 14 def discounts @discounts end |
#id ⇒ String
Order item UUID of the shipment
18 19 20 |
# File 'lib/new_store_api/models/sales_order_item_shipment.rb', line 18 def id @id end |
#price ⇒ SalesOrderPrice1
The response for retrieving price information.
22 23 24 |
# File 'lib/new_store_api/models/sales_order_item_shipment.rb', line 22 def price @price end |
#tax_lines ⇒ Array[SalesOrderTaxLine]
Detailed tax information.
26 27 28 |
# File 'lib/new_store_api/models/sales_order_item_shipment.rb', line 26 def tax_lines @tax_lines 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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/new_store_api/models/sales_order_item_shipment.rb', line 59 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil price = SalesOrderPrice1.from_hash(hash['price']) if hash['price'] # Parameter is an array, so we need to iterate through it discounts = nil unless hash['discounts'].nil? discounts = [] hash['discounts'].each do |structure| discounts << (SalesOrderDiscount.from_hash(structure) if structure) end end discounts = SKIP unless hash.key?('discounts') # Parameter is an array, so we need to iterate through it tax_lines = nil unless hash['tax_lines'].nil? tax_lines = [] hash['tax_lines'].each do |structure| tax_lines << (SalesOrderTaxLine.from_hash(structure) if structure) end end tax_lines = SKIP unless hash.key?('tax_lines') # Create object from extracted values. SalesOrderItemShipment.new(id, price, discounts, tax_lines) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 36 |
# File 'lib/new_store_api/models/sales_order_item_shipment.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['discounts'] = 'discounts' @_hash['id'] = 'id' @_hash['price'] = 'price' @_hash['tax_lines'] = 'tax_lines' @_hash end |
.nullables ⇒ Object
An array for nullable fields
47 48 49 |
# File 'lib/new_store_api/models/sales_order_item_shipment.rb', line 47 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
39 40 41 42 43 44 |
# File 'lib/new_store_api/models/sales_order_item_shipment.rb', line 39 def self.optionals %w[ discounts tax_lines ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
101 102 103 104 105 |
# File 'lib/new_store_api/models/sales_order_item_shipment.rb', line 101 def inspect class_name = self.class.name.split('::').last "<#{class_name} discounts: #{@discounts.inspect}, id: #{@id.inspect}, price:"\ " #{@price.inspect}, tax_lines: #{@tax_lines.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
94 95 96 97 98 |
# File 'lib/new_store_api/models/sales_order_item_shipment.rb', line 94 def to_s class_name = self.class.name.split('::').last "<#{class_name} discounts: #{@discounts}, id: #{@id}, price: #{@price}, tax_lines:"\ " #{@tax_lines}>" end |