Class: NewStoreApi::Item4
- Defined in:
- lib/new_store_api/models/item4.rb
Overview
Item4 Model.
Instance Attribute Summary collapse
-
#id ⇒ String
The identifier of the item.
-
#price ⇒ SalesOrderPrice1
The response for retrieving price information.
-
#status ⇒ Status1Enum
The status of a single item, doesn't reflect the order status.
-
#type ⇒ String
readonly
The status of a single item, doesn't reflect the order status.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(id = nil, price = nil, status = nil) ⇒ Item4
constructor
A new instance of Item4.
-
#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(id = nil, price = nil, status = nil) ⇒ Item4
Returns a new instance of Item4.
48 49 50 51 52 53 |
# File 'lib/new_store_api/models/item4.rb', line 48 def initialize(id = nil, price = nil, status = nil) @id = id @price = price @status = status @type = 'product' end |
Instance Attribute Details
#id ⇒ String
The identifier of the item.
14 15 16 |
# File 'lib/new_store_api/models/item4.rb', line 14 def id @id end |
#price ⇒ SalesOrderPrice1
The response for retrieving price information.
18 19 20 |
# File 'lib/new_store_api/models/item4.rb', line 18 def price @price end |
#status ⇒ Status1Enum
The status of a single item, doesn't reflect the order status
22 23 24 |
# File 'lib/new_store_api/models/item4.rb', line 22 def status @status end |
#type ⇒ String (readonly)
The status of a single item, doesn't reflect the order status
26 27 28 |
# File 'lib/new_store_api/models/item4.rb', line 26 def type @type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/new_store_api/models/item4.rb', line 56 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil price = SalesOrderPrice1.from_hash(hash['price']) if hash['price'] status = hash.key?('status') ? hash['status'] : nil # Create object from extracted values. Item4.new(id, price, status) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 36 |
# File 'lib/new_store_api/models/item4.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['price'] = 'price' @_hash['status'] = 'status' @_hash['type'] = 'type' @_hash end |
.nullables ⇒ Object
An array for nullable fields
44 45 46 |
# File 'lib/new_store_api/models/item4.rb', line 44 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
39 40 41 |
# File 'lib/new_store_api/models/item4.rb', line 39 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/new_store_api/models/item4.rb', line 72 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.price, ->(val) { SalesOrderPrice1.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.status, ->(val) { Status1Enum.validate(val) }) and APIHelper.valid_type?(value.type, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['price'], ->(val) { SalesOrderPrice1.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['status'], ->(val) { Status1Enum.validate(val) }) and APIHelper.valid_type?(value['type'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
109 110 111 112 113 |
# File 'lib/new_store_api/models/item4.rb', line 109 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, price: #{@price.inspect}, status: #{@status.inspect},"\ " type: #{@type.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
103 104 105 106 |
# File 'lib/new_store_api/models/item4.rb', line 103 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, price: #{@price}, status: #{@status}, type: #{@type}>" end |