Class: NewStoreApi::Error
- Defined in:
- lib/new_store_api/models/error.rb
Overview
Error Model.
Instance Attribute Summary collapse
-
#code ⇒ CodeEnum
A unique error code.
-
#message ⇒ String
A detailed message about the error.
-
#product_id ⇒ String
The SKU of the product with an error.
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(code = nil, message = nil, product_id = SKIP) ⇒ Error
constructor
A new instance of Error.
-
#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(code = nil, message = nil, product_id = SKIP) ⇒ Error
Returns a new instance of Error.
45 46 47 48 49 |
# File 'lib/new_store_api/models/error.rb', line 45 def initialize(code = nil, = nil, product_id = SKIP) @code = code @message = @product_id = product_id unless product_id == SKIP end |
Instance Attribute Details
#code ⇒ CodeEnum
A unique error code.
14 15 16 |
# File 'lib/new_store_api/models/error.rb', line 14 def code @code end |
#message ⇒ String
A detailed message about the error.
18 19 20 |
# File 'lib/new_store_api/models/error.rb', line 18 def @message end |
#product_id ⇒ String
The SKU of the product with an error.
22 23 24 |
# File 'lib/new_store_api/models/error.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/error.rb', line 52 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. code = hash.key?('code') ? hash['code'] : nil = hash.key?('message') ? hash['message'] : nil product_id = hash.key?('product_id') ? hash['product_id'] : SKIP # Create object from extracted values. Error.new(code, , product_id) 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/error.rb', line 25 def self.names @_hash = {} if @_hash.nil? @_hash['code'] = 'code' @_hash['message'] = 'message' @_hash['product_id'] = 'product_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
41 42 43 |
# File 'lib/new_store_api/models/error.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/error.rb', line 34 def self.optionals %w[ product_id ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
73 74 75 76 77 |
# File 'lib/new_store_api/models/error.rb', line 73 def inspect class_name = self.class.name.split('::').last "<#{class_name} code: #{@code.inspect}, message: #{@message.inspect}, product_id:"\ " #{@product_id.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
67 68 69 70 |
# File 'lib/new_store_api/models/error.rb', line 67 def to_s class_name = self.class.name.split('::').last "<#{class_name} code: #{@code}, message: #{@message}, product_id: #{@product_id}>" end |