Class: ShellSmartPayApi::MppError
- Defined in:
- lib/shell_smart_pay_api/models/mpp_error.rb
Overview
MppError Model.
Instance Attribute Summary collapse
-
#message ⇒ String
Descriptive, human readable error message.
-
#reason ⇒ String
Additional classification specific for each error type e.g.
-
#subject ⇒ String
Identifier of the related object e.g.
-
#subject_type ⇒ String
Type of the object related to the error e.g.
-
#type ⇒ String
Type of the error e.g.
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(message = SKIP, reason = SKIP, subject = SKIP, subject_type = SKIP, type = SKIP) ⇒ MppError
constructor
A new instance of MppError.
-
#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(message = SKIP, reason = SKIP, subject = SKIP, subject_type = SKIP, type = SKIP) ⇒ MppError
Returns a new instance of MppError.
63 64 65 66 67 68 69 70 |
# File 'lib/shell_smart_pay_api/models/mpp_error.rb', line 63 def initialize( = SKIP, reason = SKIP, subject = SKIP, subject_type = SKIP, type = SKIP) = unless == SKIP @reason = reason unless reason == SKIP @subject = subject unless subject == SKIP @subject_type = subject_type unless subject_type == SKIP @type = type unless type == SKIP end |
Instance Attribute Details
#message ⇒ String
Descriptive, human readable error message. Description of the error (e.g. This field is required and must to be between 1 and 255 characters long)
15 16 17 |
# File 'lib/shell_smart_pay_api/models/mpp_error.rb', line 15 def end |
#reason ⇒ String
Additional classification specific for each error type e.g. ‘noStock’. The nature of the issue (e.g. missing)
20 21 22 |
# File 'lib/shell_smart_pay_api/models/mpp_error.rb', line 20 def reason @reason end |
#subject ⇒ String
Identifier of the related object e.g. ‘1’. The field/attribute with an issue (e.g. First Name)
25 26 27 |
# File 'lib/shell_smart_pay_api/models/mpp_error.rb', line 25 def subject @subject end |
#subject_type ⇒ String
Type of the object related to the error e.g. ‘entry’. The item it relates to (e.g. Parameter)
30 31 32 |
# File 'lib/shell_smart_pay_api/models/mpp_error.rb', line 30 def subject_type @subject_type end |
#type ⇒ String
Type of the error e.g. ‘LowStockError’, ‘Validation Error’
34 35 36 |
# File 'lib/shell_smart_pay_api/models/mpp_error.rb', line 34 def type @type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/shell_smart_pay_api/models/mpp_error.rb', line 73 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. = hash.key?('message') ? hash['message'] : SKIP reason = hash.key?('reason') ? hash['reason'] : SKIP subject = hash.key?('subject') ? hash['subject'] : SKIP subject_type = hash.key?('subjectType') ? hash['subjectType'] : SKIP type = hash.key?('type') ? hash['type'] : SKIP # Create object from extracted values. MppError.new(, reason, subject, subject_type, type) end |
.names ⇒ Object
A mapping from model property names to API property names.
37 38 39 40 41 42 43 44 45 |
# File 'lib/shell_smart_pay_api/models/mpp_error.rb', line 37 def self.names @_hash = {} if @_hash.nil? @_hash['message'] = 'message' @_hash['reason'] = 'reason' @_hash['subject'] = 'subject' @_hash['subject_type'] = 'subjectType' @_hash['type'] = 'type' @_hash end |
.nullables ⇒ Object
An array for nullable fields
59 60 61 |
# File 'lib/shell_smart_pay_api/models/mpp_error.rb', line 59 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
48 49 50 51 52 53 54 55 56 |
# File 'lib/shell_smart_pay_api/models/mpp_error.rb', line 48 def self.optionals %w[ message reason subject subject_type type ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
99 100 101 102 103 |
# File 'lib/shell_smart_pay_api/models/mpp_error.rb', line 99 def inspect class_name = self.class.name.split('::').last "<#{class_name} message: #{@message.inspect}, reason: #{@reason.inspect}, subject:"\ " #{@subject.inspect}, subject_type: #{@subject_type.inspect}, type: #{@type.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
92 93 94 95 96 |
# File 'lib/shell_smart_pay_api/models/mpp_error.rb', line 92 def to_s class_name = self.class.name.split('::').last "<#{class_name} message: #{@message}, reason: #{@reason}, subject: #{@subject},"\ " subject_type: #{@subject_type}, type: #{@type}>" end |