Class: NewStoreApi::RoutingSimulationLineItem
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- NewStoreApi::RoutingSimulationLineItem
- Defined in:
- lib/new_store_api/models/routing_simulation_line_item.rb
Overview
Order line item supplied for a routing simulation run.
Instance Attribute Summary collapse
-
#line_item_id ⇒ String
Unique identifier for the line item in the simulated order.
-
#price ⇒ Float
Unit price used by routing reducers that depend on order amount.
-
#product_id ⇒ String
Catalog product identifier for the line item.
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_item_id = nil, product_id = nil, price = 0) ⇒ RoutingSimulationLineItem
constructor
A new instance of RoutingSimulationLineItem.
-
#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_item_id = nil, product_id = nil, price = 0) ⇒ RoutingSimulationLineItem
Returns a new instance of RoutingSimulationLineItem.
45 46 47 48 49 |
# File 'lib/new_store_api/models/routing_simulation_line_item.rb', line 45 def initialize(line_item_id = nil, product_id = nil, price = 0) @line_item_id = line_item_id @price = price unless price == SKIP @product_id = product_id end |
Instance Attribute Details
#line_item_id ⇒ String
Unique identifier for the line item in the simulated order.
14 15 16 |
# File 'lib/new_store_api/models/routing_simulation_line_item.rb', line 14 def line_item_id @line_item_id end |
#price ⇒ Float
Unit price used by routing reducers that depend on order amount.
18 19 20 |
# File 'lib/new_store_api/models/routing_simulation_line_item.rb', line 18 def price @price end |
#product_id ⇒ String
Catalog product identifier for the line item.
22 23 24 |
# File 'lib/new_store_api/models/routing_simulation_line_item.rb', line 22 def product_id @product_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/new_store_api/models/routing_simulation_line_item.rb', line 52 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. line_item_id = hash.key?('line_item_id') ? hash['line_item_id'] : nil product_id = hash.key?('product_id') ? hash['product_id'] : nil price = hash['price'] ||= 0 # Create object from extracted values. RoutingSimulationLineItem.new(line_item_id, product_id, price) end |
.names ⇒ Object
A mapping from model property names to API property names.
25 26 27 28 29 30 31 |
# File 'lib/new_store_api/models/routing_simulation_line_item.rb', line 25 def self.names @_hash = {} if @_hash.nil? @_hash['line_item_id'] = 'line_item_id' @_hash['price'] = 'price' @_hash['product_id'] = 'product_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
41 42 43 |
# File 'lib/new_store_api/models/routing_simulation_line_item.rb', line 41 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
34 35 36 37 38 |
# File 'lib/new_store_api/models/routing_simulation_line_item.rb', line 34 def self.optionals %w[ price ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
74 75 76 77 78 |
# File 'lib/new_store_api/models/routing_simulation_line_item.rb', line 74 def inspect class_name = self.class.name.split('::').last "<#{class_name} line_item_id: #{@line_item_id.inspect}, price: #{@price.inspect},"\ " product_id: #{@product_id.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
67 68 69 70 71 |
# File 'lib/new_store_api/models/routing_simulation_line_item.rb', line 67 def to_s class_name = self.class.name.split('::').last "<#{class_name} line_item_id: #{@line_item_id}, price: #{@price}, product_id:"\ " #{@product_id}>" end |