Class: NewStoreApi::LineItem
- Defined in:
- lib/new_store_api/models/line_item.rb
Overview
LineItem Model.
Instance Attribute Summary collapse
-
#line_item_id ⇒ String
TODO: Write general description for this method.
-
#product_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(product_id = nil, line_item_id = SKIP) ⇒ LineItem
constructor
A new instance of LineItem.
-
#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(product_id = nil, line_item_id = SKIP) ⇒ LineItem
Returns a new instance of LineItem.
42 43 44 45 |
# File 'lib/new_store_api/models/line_item.rb', line 42 def initialize(product_id = nil, line_item_id = SKIP) @line_item_id = line_item_id unless line_item_id == SKIP @product_id = product_id end |
Instance Attribute Details
#line_item_id ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/new_store_api/models/line_item.rb', line 14 def line_item_id @line_item_id end |
#product_id ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/new_store_api/models/line_item.rb', line 18 def product_id @product_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/new_store_api/models/line_item.rb', line 48 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. product_id = hash.key?('product_id') ? hash['product_id'] : nil line_item_id = hash.key?('line_item_id') ? hash['line_item_id'] : SKIP # Create object from extracted values. LineItem.new(product_id, line_item_id) end |
.names ⇒ Object
A mapping from model property names to API property names.
21 22 23 24 25 26 |
# File 'lib/new_store_api/models/line_item.rb', line 21 def self.names @_hash = {} if @_hash.nil? @_hash['line_item_id'] = 'line_item_id' @_hash['product_id'] = 'product_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
36 37 38 39 40 |
# File 'lib/new_store_api/models/line_item.rb', line 36 def self.nullables %w[ line_item_id ] end |
.optionals ⇒ Object
An array for optional fields
29 30 31 32 33 |
# File 'lib/new_store_api/models/line_item.rb', line 29 def self.optionals %w[ line_item_id ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
67 68 69 70 71 |
# File 'lib/new_store_api/models/line_item.rb', line 67 def inspect class_name = self.class.name.split('::').last "<#{class_name} line_item_id: #{@line_item_id.inspect}, product_id:"\ " #{@product_id.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
61 62 63 64 |
# File 'lib/new_store_api/models/line_item.rb', line 61 def to_s class_name = self.class.name.split('::').last "<#{class_name} line_item_id: #{@line_item_id}, product_id: #{@product_id}>" end |