Class: WalmartApIs::OrderLine
- Defined in:
- lib/walmart_ap_is/models/order_line.rb
Overview
OrderLine Model.
Instance Attribute Summary collapse
-
#fulfillment_option ⇒ FulfillmentOption
Walmart Ship Node identifier for WFS orders.
-
#item_price ⇒ Money
TODO: Write general description for this method.
-
#line_number ⇒ String
TODO: Write general description for this method.
-
#line_status ⇒ LineStatus
TODO: Write general description for this method.
-
#product_name ⇒ String
TODO: Write general description for this method.
-
#quantity ⇒ QuantityWithUnit
TODO: Write general description for this method.
-
#seller_sku ⇒ String
TODO: Write general description for this method.
-
#ship_node ⇒ String
Walmart Ship Node identifier for WFS orders.
-
#walmart_item_id ⇒ String
TODO: Write general description for this method.
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(line_number:, seller_sku:, quantity:, item_price:, walmart_item_id: SKIP, product_name: SKIP, line_status: SKIP, ship_node: SKIP, fulfillment_option: SKIP, additional_properties: nil) ⇒ OrderLine
constructor
A new instance of OrderLine.
-
#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(line_number:, seller_sku:, quantity:, item_price:, walmart_item_id: SKIP, product_name: SKIP, line_status: SKIP, ship_node: SKIP, fulfillment_option: SKIP, additional_properties: nil) ⇒ OrderLine
Returns a new instance of OrderLine.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/walmart_ap_is/models/order_line.rb', line 79 def initialize(line_number:, seller_sku:, quantity:, item_price:, walmart_item_id: SKIP, product_name: SKIP, line_status: SKIP, ship_node: SKIP, fulfillment_option: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @line_number = line_number @seller_sku = seller_sku @walmart_item_id = walmart_item_id unless walmart_item_id == SKIP @product_name = product_name unless product_name == SKIP @quantity = quantity @item_price = item_price @line_status = line_status unless line_status == SKIP @ship_node = ship_node unless ship_node == SKIP @fulfillment_option = fulfillment_option unless fulfillment_option == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#fulfillment_option ⇒ FulfillmentOption
Walmart Ship Node identifier for WFS orders
46 47 48 |
# File 'lib/walmart_ap_is/models/order_line.rb', line 46 def fulfillment_option @fulfillment_option end |
#item_price ⇒ Money
TODO: Write general description for this method
34 35 36 |
# File 'lib/walmart_ap_is/models/order_line.rb', line 34 def item_price @item_price end |
#line_number ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/walmart_ap_is/models/order_line.rb', line 14 def line_number @line_number end |
#line_status ⇒ LineStatus
TODO: Write general description for this method
38 39 40 |
# File 'lib/walmart_ap_is/models/order_line.rb', line 38 def line_status @line_status end |
#product_name ⇒ String
TODO: Write general description for this method
26 27 28 |
# File 'lib/walmart_ap_is/models/order_line.rb', line 26 def product_name @product_name end |
#quantity ⇒ QuantityWithUnit
TODO: Write general description for this method
30 31 32 |
# File 'lib/walmart_ap_is/models/order_line.rb', line 30 def quantity @quantity end |
#seller_sku ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/walmart_ap_is/models/order_line.rb', line 18 def seller_sku @seller_sku end |
#ship_node ⇒ String
Walmart Ship Node identifier for WFS orders
42 43 44 |
# File 'lib/walmart_ap_is/models/order_line.rb', line 42 def ship_node @ship_node end |
#walmart_item_id ⇒ String
TODO: Write general description for this method
22 23 24 |
# File 'lib/walmart_ap_is/models/order_line.rb', line 22 def walmart_item_id @walmart_item_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
99 100 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 |
# File 'lib/walmart_ap_is/models/order_line.rb', line 99 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. line_number = hash.key?('lineNumber') ? hash['lineNumber'] : nil seller_sku = hash.key?('sellerSku') ? hash['sellerSku'] : nil quantity = QuantityWithUnit.from_hash(hash['quantity']) if hash['quantity'] item_price = Money.from_hash(hash['itemPrice']) if hash['itemPrice'] walmart_item_id = hash.key?('walmartItemId') ? hash['walmartItemId'] : SKIP product_name = hash.key?('productName') ? hash['productName'] : SKIP line_status = hash.key?('lineStatus') ? hash['lineStatus'] : SKIP ship_node = hash.key?('shipNode') ? hash['shipNode'] : SKIP fulfillment_option = hash.key?('fulfillmentOption') ? hash['fulfillmentOption'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. OrderLine.new(line_number: line_number, seller_sku: seller_sku, quantity: quantity, item_price: item_price, walmart_item_id: walmart_item_id, product_name: product_name, line_status: line_status, ship_node: ship_node, fulfillment_option: fulfillment_option, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/walmart_ap_is/models/order_line.rb', line 49 def self.names @_hash = {} if @_hash.nil? @_hash['line_number'] = 'lineNumber' @_hash['seller_sku'] = 'sellerSku' @_hash['walmart_item_id'] = 'walmartItemId' @_hash['product_name'] = 'productName' @_hash['quantity'] = 'quantity' @_hash['item_price'] = 'itemPrice' @_hash['line_status'] = 'lineStatus' @_hash['ship_node'] = 'shipNode' @_hash['fulfillment_option'] = 'fulfillmentOption' @_hash end |
.nullables ⇒ Object
An array for nullable fields
75 76 77 |
# File 'lib/walmart_ap_is/models/order_line.rb', line 75 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
64 65 66 67 68 69 70 71 72 |
# File 'lib/walmart_ap_is/models/order_line.rb', line 64 def self.optionals %w[ walmart_item_id product_name line_status ship_node fulfillment_option ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
146 147 148 149 150 151 152 153 |
# File 'lib/walmart_ap_is/models/order_line.rb', line 146 def inspect class_name = self.class.name.split('::').last "<#{class_name} line_number: #{@line_number.inspect}, seller_sku: #{@seller_sku.inspect},"\ " walmart_item_id: #{@walmart_item_id.inspect}, product_name: #{@product_name.inspect},"\ " quantity: #{@quantity.inspect}, item_price: #{@item_price.inspect}, line_status:"\ " #{@line_status.inspect}, ship_node: #{@ship_node.inspect}, fulfillment_option:"\ " #{@fulfillment_option.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
136 137 138 139 140 141 142 143 |
# File 'lib/walmart_ap_is/models/order_line.rb', line 136 def to_s class_name = self.class.name.split('::').last "<#{class_name} line_number: #{@line_number}, seller_sku: #{@seller_sku}, walmart_item_id:"\ " #{@walmart_item_id}, product_name: #{@product_name}, quantity: #{@quantity}, item_price:"\ " #{@item_price}, line_status: #{@line_status}, ship_node: #{@ship_node},"\ " fulfillment_option: #{@fulfillment_option}, additional_properties:"\ " #{@additional_properties}>" end |