Class: ShellSmartPayApi::MppError

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/shell_smart_pay_api/models/mpp_error.rb

Overview

MppError Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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(message = SKIP, reason = SKIP, subject = SKIP,
               subject_type = SKIP, type = SKIP)
  @message = message unless message == 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

#messageString

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)

Returns:

  • (String)


15
16
17
# File 'lib/shell_smart_pay_api/models/mpp_error.rb', line 15

def message
  @message
end

#reasonString

Additional classification specific for each error type e.g. ‘noStock’. The nature of the issue (e.g. missing)

Returns:

  • (String)


20
21
22
# File 'lib/shell_smart_pay_api/models/mpp_error.rb', line 20

def reason
  @reason
end

#subjectString

Identifier of the related object e.g. ‘1’. The field/attribute with an issue (e.g. First Name)

Returns:

  • (String)


25
26
27
# File 'lib/shell_smart_pay_api/models/mpp_error.rb', line 25

def subject
  @subject
end

#subject_typeString

Type of the object related to the error e.g. ‘entry’. The item it relates to (e.g. Parameter)

Returns:

  • (String)


30
31
32
# File 'lib/shell_smart_pay_api/models/mpp_error.rb', line 30

def subject_type
  @subject_type
end

#typeString

Type of the error e.g. ‘LowStockError’, ‘Validation Error’

Returns:

  • (String)


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.

  message = 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(message,
               reason,
               subject,
               subject_type,
               type)
end

.namesObject

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

.nullablesObject

An array for nullable fields



59
60
61
# File 'lib/shell_smart_pay_api/models/mpp_error.rb', line 59

def self.nullables
  []
end

.optionalsObject

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

#inspectObject

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_sObject

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