Class: NewStoreApi::SalesOrder
- Defined in:
- lib/new_store_api/models/sales_order.rb
Overview
SalesOrder Model.
Instance Attribute Summary collapse
-
#catalog ⇒ String
The catalog identifier (shop) associated with the order.
-
#channel_type ⇒ SalesOrderChannelTypeEnum
The channel through which the order was placed.
-
#currency ⇒ String
Currency code (ISO 4217) used in internal accounting.
-
#fulfillment_type ⇒ SalesOrderFulfillmentTypeEnum
The fulfillment type of the order.
-
#id ⇒ String
External ID of the order.
-
#items ⇒ Array[SalesOrderItem]
A list of line items which were ordered.
-
#origin ⇒ SalesOrderOriginEnum
Describes in which Order Management System the order originated from.
-
#origin_id ⇒ String
The identifier of the order from the Order Management System where it originated from.
-
#placed_at ⇒ DateTime
The time when the order was placed.
-
#status ⇒ SalesOrderStatusEnum
Current status of the sales order.
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(channel_type = nil, currency = nil, fulfillment_type = nil, id = nil, items = nil, origin = nil, origin_id = nil, placed_at = nil, status = nil, catalog = SKIP) ⇒ SalesOrder
constructor
A new instance of SalesOrder.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_placed_at ⇒ Object
-
#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(channel_type = nil, currency = nil, fulfillment_type = nil, id = nil, items = nil, origin = nil, origin_id = nil, placed_at = nil, status = nil, catalog = SKIP) ⇒ SalesOrder
Returns a new instance of SalesOrder.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/new_store_api/models/sales_order.rb', line 85 def initialize(channel_type = nil, currency = nil, fulfillment_type = nil, id = nil, items = nil, origin = nil, origin_id = nil, placed_at = nil, status = nil, catalog = SKIP) @catalog = catalog unless catalog == SKIP @channel_type = channel_type @currency = currency @fulfillment_type = fulfillment_type @id = id @items = items @origin = origin @origin_id = origin_id @placed_at = placed_at @status = status end |
Instance Attribute Details
#catalog ⇒ String
The catalog identifier (shop) associated with the order.
15 16 17 |
# File 'lib/new_store_api/models/sales_order.rb', line 15 def catalog @catalog end |
#channel_type ⇒ SalesOrderChannelTypeEnum
The channel through which the order was placed.
19 20 21 |
# File 'lib/new_store_api/models/sales_order.rb', line 19 def channel_type @channel_type end |
#currency ⇒ String
Currency code (ISO 4217) used in internal accounting
23 24 25 |
# File 'lib/new_store_api/models/sales_order.rb', line 23 def currency @currency end |
#fulfillment_type ⇒ SalesOrderFulfillmentTypeEnum
The fulfillment type of the order. In case of mixed cart orders, fulfillment type is always 'multiple'
28 29 30 |
# File 'lib/new_store_api/models/sales_order.rb', line 28 def fulfillment_type @fulfillment_type end |
#id ⇒ String
External ID of the order
32 33 34 |
# File 'lib/new_store_api/models/sales_order.rb', line 32 def id @id end |
#items ⇒ Array[SalesOrderItem]
A list of line items which were ordered
36 37 38 |
# File 'lib/new_store_api/models/sales_order.rb', line 36 def items @items end |
#origin ⇒ SalesOrderOriginEnum
Describes in which Order Management System the order originated from.
40 41 42 |
# File 'lib/new_store_api/models/sales_order.rb', line 40 def origin @origin end |
#origin_id ⇒ String
The identifier of the order from the Order Management System where it originated from. If it originated in Newstore, it must be the identifier assigned to the order during the order creation process.
46 47 48 |
# File 'lib/new_store_api/models/sales_order.rb', line 46 def origin_id @origin_id end |
#placed_at ⇒ DateTime
The time when the order was placed. It should follow https://tools.ietf.org/html/rfc3339 in UTC.
51 52 53 |
# File 'lib/new_store_api/models/sales_order.rb', line 51 def placed_at @placed_at end |
#status ⇒ SalesOrderStatusEnum
Current status of the sales order
55 56 57 |
# File 'lib/new_store_api/models/sales_order.rb', line 55 def status @status end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/new_store_api/models/sales_order.rb', line 101 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. channel_type = hash.key?('channel_type') ? hash['channel_type'] : nil currency = hash.key?('currency') ? hash['currency'] : nil fulfillment_type = hash.key?('fulfillment_type') ? hash['fulfillment_type'] : nil id = hash.key?('id') ? hash['id'] : nil # Parameter is an array, so we need to iterate through it items = nil unless hash['items'].nil? items = [] hash['items'].each do |structure| items << (SalesOrderItem.from_hash(structure) if structure) end end items = nil unless hash.key?('items') origin = hash.key?('origin') ? hash['origin'] : nil origin_id = hash.key?('origin_id') ? hash['origin_id'] : nil placed_at = if hash.key?('placed_at') (DateTimeHelper.from_rfc3339(hash['placed_at']) if hash['placed_at']) end status = hash.key?('status') ? hash['status'] : nil catalog = hash.key?('catalog') ? hash['catalog'] : SKIP # Create object from extracted values. SalesOrder.new(channel_type, currency, fulfillment_type, id, items, origin, origin_id, placed_at, status, catalog) end |
.names ⇒ Object
A mapping from model property names to API property names.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/new_store_api/models/sales_order.rb', line 58 def self.names @_hash = {} if @_hash.nil? @_hash['catalog'] = 'catalog' @_hash['channel_type'] = 'channel_type' @_hash['currency'] = 'currency' @_hash['fulfillment_type'] = 'fulfillment_type' @_hash['id'] = 'id' @_hash['items'] = 'items' @_hash['origin'] = 'origin' @_hash['origin_id'] = 'origin_id' @_hash['placed_at'] = 'placed_at' @_hash['status'] = 'status' @_hash end |
.nullables ⇒ Object
An array for nullable fields
81 82 83 |
# File 'lib/new_store_api/models/sales_order.rb', line 81 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
74 75 76 77 78 |
# File 'lib/new_store_api/models/sales_order.rb', line 74 def self.optionals %w[ catalog ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
155 156 157 158 159 160 161 |
# File 'lib/new_store_api/models/sales_order.rb', line 155 def inspect class_name = self.class.name.split('::').last "<#{class_name} catalog: #{@catalog.inspect}, channel_type: #{@channel_type.inspect},"\ " currency: #{@currency.inspect}, fulfillment_type: #{@fulfillment_type.inspect}, id:"\ " #{@id.inspect}, items: #{@items.inspect}, origin: #{@origin.inspect}, origin_id:"\ " #{@origin_id.inspect}, placed_at: #{@placed_at.inspect}, status: #{@status.inspect}>" end |
#to_custom_placed_at ⇒ Object
141 142 143 |
# File 'lib/new_store_api/models/sales_order.rb', line 141 def to_custom_placed_at DateTimeHelper.to_rfc3339(placed_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
146 147 148 149 150 151 152 |
# File 'lib/new_store_api/models/sales_order.rb', line 146 def to_s class_name = self.class.name.split('::').last "<#{class_name} catalog: #{@catalog}, channel_type: #{@channel_type}, currency:"\ " #{@currency}, fulfillment_type: #{@fulfillment_type}, id: #{@id}, items: #{@items},"\ " origin: #{@origin}, origin_id: #{@origin_id}, placed_at: #{@placed_at}, status:"\ " #{@status}>" end |