Class: NewStoreApi::SalesOrderItemV2

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

Overview

SalesOrderItemV2 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(id = nil, price = nil, product_attributes = nil, status = nil, extended_attributes = SKIP, external_identifier = SKIP, product_id = SKIP) ⇒ SalesOrderItemV2

Returns a new instance of SalesOrderItemV2.



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/new_store_api/models/sales_order_item_v2.rb', line 71

def initialize(id = nil, price = nil, product_attributes = nil,
               status = nil, extended_attributes = SKIP,
               external_identifier = SKIP, product_id = SKIP)
  @extended_attributes = extended_attributes unless extended_attributes == SKIP
  @external_identifier = external_identifier unless external_identifier == SKIP
  @id = id
  @price = price
  @product_attributes = product_attributes
  @product_id = product_id unless product_id == SKIP
  @status = status
end

Instance Attribute Details

#extended_attributesArray[SalesOrderExtendedAttribute]

Extended attributes of the sales order item.

Returns:



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

def extended_attributes
  @extended_attributes
end

#external_identifierSalesOrderExternalIdentifier

External identifier for the order item



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

def external_identifier
  @external_identifier
end

#idString

The identifier of the order item

Returns:

  • (String)


22
23
24
# File 'lib/new_store_api/models/sales_order_item_v2.rb', line 22

def id
  @id
end

#priceSalesOrderPrice1

The response for retrieving price information.

Returns:



26
27
28
# File 'lib/new_store_api/models/sales_order_item_v2.rb', line 26

def price
  @price
end

#product_attributesSalesOrderProductAttributes

Additional product-related information.



30
31
32
# File 'lib/new_store_api/models/sales_order_item_v2.rb', line 30

def product_attributes
  @product_attributes
end

#product_idString

Product ID for order item.

Returns:

  • (String)


34
35
36
# File 'lib/new_store_api/models/sales_order_item_v2.rb', line 34

def product_id
  @product_id
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.



40
41
42
# File 'lib/new_store_api/models/sales_order_item_v2.rb', line 40

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
114
115
# File 'lib/new_store_api/models/sales_order_item_v2.rb', line 84

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']
  product_attributes = SalesOrderProductAttributes.from_hash(hash['product_attributes']) if
    hash['product_attributes']
  status = hash.key?('status') ? hash['status'] : nil
  # Parameter is an array, so we need to iterate through it
  extended_attributes = nil
  unless hash['extended_attributes'].nil?
    extended_attributes = []
    hash['extended_attributes'].each do |structure|
      extended_attributes << (SalesOrderExtendedAttribute.from_hash(structure) if structure)
    end
  end

  extended_attributes = SKIP unless hash.key?('extended_attributes')
  external_identifier = SalesOrderExternalIdentifier.from_hash(hash['external_identifier']) if
    hash['external_identifier']
  product_id = hash.key?('product_id') ? hash['product_id'] : SKIP

  # Create object from extracted values.
  SalesOrderItemV2.new(id,
                       price,
                       product_attributes,
                       status,
                       extended_attributes,
                       external_identifier,
                       product_id)
end

.namesObject

A mapping from model property names to API property names.



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/new_store_api/models/sales_order_item_v2.rb', line 43

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

.nullablesObject

An array for nullable fields



65
66
67
68
69
# File 'lib/new_store_api/models/sales_order_item_v2.rb', line 65

def self.nullables
  %w[
    extended_attributes
  ]
end

.optionalsObject

An array for optional fields



56
57
58
59
60
61
62
# File 'lib/new_store_api/models/sales_order_item_v2.rb', line 56

def self.optionals
  %w[
    extended_attributes
    external_identifier
    product_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



126
127
128
129
130
131
132
# File 'lib/new_store_api/models/sales_order_item_v2.rb', line 126

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

#to_sObject

Provides a human-readable string representation of the object.



118
119
120
121
122
123
# File 'lib/new_store_api/models/sales_order_item_v2.rb', line 118

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