Class: NewStoreApi::SalesOrderItem

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/sales_order_item.rb

Overview

SalesOrderItem Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(external_identifier = nil, id = nil, origin_id = nil, price = nil, product_attributes = nil, status = nil) ⇒ SalesOrderItem

Returns a new instance of SalesOrderItem.



62
63
64
65
66
67
68
69
70
# File 'lib/new_store_api/models/sales_order_item.rb', line 62

def initialize(external_identifier = nil, id = nil, origin_id = nil,
               price = nil, product_attributes = nil, status = nil)
  @external_identifier = external_identifier
  @id = id
  @origin_id = origin_id
  @price = price
  @product_attributes = product_attributes
  @status = status
end

Instance Attribute Details

#external_identifierSalesOrderExternalIdentifier

External identifier for the order item



14
15
16
# File 'lib/new_store_api/models/sales_order_item.rb', line 14

def external_identifier
  @external_identifier
end

#idString

External ID of the item

Returns:

  • (String)


18
19
20
# File 'lib/new_store_api/models/sales_order_item.rb', line 18

def id
  @id
end

#origin_idString

If the origin of the order is 'newstore', this should be the order item identifier. If the order originated in an external system, it should be the identifier from the external system.

Returns:

  • (String)


24
25
26
# File 'lib/new_store_api/models/sales_order_item.rb', line 24

def origin_id
  @origin_id
end

#priceSalesOrderPrice1

The response for retrieving price information.

Returns:



28
29
30
# File 'lib/new_store_api/models/sales_order_item.rb', line 28

def price
  @price
end

#product_attributesSalesOrderProductAttributes

Additional product-related information.



32
33
34
# File 'lib/new_store_api/models/sales_order_item.rb', line 32

def product_attributes
  @product_attributes
end

#statusSalesOrderItemStatusEnum

Current status of the order item. 'pending' means the item is in the grace period, 'on_hold' means the item couldn't be fulfilled and is in a conflict status.



38
39
40
# File 'lib/new_store_api/models/sales_order_item.rb', line 38

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/new_store_api/models/sales_order_item.rb', line 73

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  external_identifier = SalesOrderExternalIdentifier.from_hash(hash['external_identifier']) if
    hash['external_identifier']
  id = hash.key?('id') ? hash['id'] : nil
  origin_id = hash.key?('origin_id') ? hash['origin_id'] : nil
  price = SalesOrderPrice1.from_hash(hash['price']) if hash['price']
  product_attributes = SalesOrderProductAttributes.from_hash(hash['product_attributes']) if
    hash['product_attributes']
  status = hash.key?('status') ? hash['status'] : nil

  # Create object from extracted values.
  SalesOrderItem.new(external_identifier,
                     id,
                     origin_id,
                     price,
                     product_attributes,
                     status)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
49
50
# File 'lib/new_store_api/models/sales_order_item.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['external_identifier'] = 'external_identifier'
  @_hash['id'] = 'id'
  @_hash['origin_id'] = 'origin_id'
  @_hash['price'] = 'price'
  @_hash['product_attributes'] = 'product_attributes'
  @_hash['status'] = 'status'
  @_hash
end

.nullablesObject

An array for nullable fields



58
59
60
# File 'lib/new_store_api/models/sales_order_item.rb', line 58

def self.nullables
  []
end

.optionalsObject

An array for optional fields



53
54
55
# File 'lib/new_store_api/models/sales_order_item.rb', line 53

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



104
105
106
107
108
109
# File 'lib/new_store_api/models/sales_order_item.rb', line 104

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} external_identifier: #{@external_identifier.inspect}, id: #{@id.inspect},"\
  " origin_id: #{@origin_id.inspect}, price: #{@price.inspect}, product_attributes:"\
  " #{@product_attributes.inspect}, status: #{@status.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



96
97
98
99
100
101
# File 'lib/new_store_api/models/sales_order_item.rb', line 96

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} external_identifier: #{@external_identifier}, id: #{@id}, origin_id:"\
  " #{@origin_id}, price: #{@price}, product_attributes: #{@product_attributes}, status:"\
  " #{@status}>"
end