Class: ShellSmartPayApi::Product
- Defined in:
- lib/shell_smart_pay_api/models/product.rb
Overview
Product Model.
Instance Attribute Summary collapse
-
#product_id ⇒ String
TODO: Write general description for this method.
-
#product_name ⇒ String
TODO: Write general description for this method.
-
#unit_price ⇒ Float
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 = SKIP, product_name = SKIP, unit_price = SKIP) ⇒ Product
constructor
A new instance of Product.
-
#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 = SKIP, product_name = SKIP, unit_price = SKIP) ⇒ Product
Returns a new instance of Product.
47 48 49 50 51 |
# File 'lib/shell_smart_pay_api/models/product.rb', line 47 def initialize(product_id = SKIP, product_name = SKIP, unit_price = SKIP) @product_id = product_id unless product_id == SKIP @product_name = product_name unless product_name == SKIP @unit_price = unit_price unless unit_price == SKIP end |
Instance Attribute Details
#product_id ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/shell_smart_pay_api/models/product.rb', line 14 def product_id @product_id end |
#product_name ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/shell_smart_pay_api/models/product.rb', line 18 def product_name @product_name end |
#unit_price ⇒ Float
TODO: Write general description for this method
22 23 24 |
# File 'lib/shell_smart_pay_api/models/product.rb', line 22 def unit_price @unit_price end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/shell_smart_pay_api/models/product.rb', line 54 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. product_id = hash.key?('productId') ? hash['productId'] : SKIP product_name = hash.key?('productName') ? hash['productName'] : SKIP unit_price = hash.key?('unitPrice') ? hash['unitPrice'] : SKIP # Create object from extracted values. Product.new(product_id, product_name, unit_price) end |
.names ⇒ Object
A mapping from model property names to API property names.
25 26 27 28 29 30 31 |
# File 'lib/shell_smart_pay_api/models/product.rb', line 25 def self.names @_hash = {} if @_hash.nil? @_hash['product_id'] = 'productId' @_hash['product_name'] = 'productName' @_hash['unit_price'] = 'unitPrice' @_hash end |
.nullables ⇒ Object
An array for nullable fields
43 44 45 |
# File 'lib/shell_smart_pay_api/models/product.rb', line 43 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
34 35 36 37 38 39 40 |
# File 'lib/shell_smart_pay_api/models/product.rb', line 34 def self.optionals %w[ product_id product_name unit_price ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
76 77 78 79 80 |
# File 'lib/shell_smart_pay_api/models/product.rb', line 76 def inspect class_name = self.class.name.split('::').last "<#{class_name} product_id: #{@product_id.inspect}, product_name: #{@product_name.inspect},"\ " unit_price: #{@unit_price.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
69 70 71 72 73 |
# File 'lib/shell_smart_pay_api/models/product.rb', line 69 def to_s class_name = self.class.name.split('::').last "<#{class_name} product_id: #{@product_id}, product_name: #{@product_name}, unit_price:"\ " #{@unit_price}>" end |