Class: Verizon::IErrorMessage

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/verizon/models/i_error_message.rb

Overview

Error message.

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(error_code: SKIP, error_message: SKIP, http_status_code: SKIP, detail_error_message: SKIP, additional_properties: nil) ⇒ IErrorMessage

Returns a new instance of IErrorMessage.



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/verizon/models/i_error_message.rb', line 53

def initialize(error_code: SKIP, error_message: SKIP,
               http_status_code: SKIP, detail_error_message: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @error_code = error_code unless error_code == SKIP
  @error_message = error_message unless error_message == SKIP
  @http_status_code = http_status_code unless http_status_code == SKIP
  @detail_error_message = detail_error_message unless detail_error_message == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#detail_error_messageString

More detail and information about the HTML error code.

Returns:

  • (String)


26
27
28
# File 'lib/verizon/models/i_error_message.rb', line 26

def detail_error_message
  @detail_error_message
end

#error_codeErrorResponseCode

Error Code.

Returns:



14
15
16
# File 'lib/verizon/models/i_error_message.rb', line 14

def error_code
  @error_code
end

#error_messageString

Details and additional information about the error code.

Returns:

  • (String)


18
19
20
# File 'lib/verizon/models/i_error_message.rb', line 18

def error_message
  @error_message
end

#http_status_codeHttpStatusCode

HTML error code and description.

Returns:



22
23
24
# File 'lib/verizon/models/i_error_message.rb', line 22

def http_status_code
  @http_status_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/verizon/models/i_error_message.rb', line 67

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  error_code = hash.key?('errorCode') ? hash['errorCode'] : SKIP
  error_message = hash.key?('errorMessage') ? hash['errorMessage'] : SKIP
  http_status_code =
    hash.key?('httpStatusCode') ? hash['httpStatusCode'] : SKIP
  detail_error_message =
    hash.key?('detailErrorMessage') ? hash['detailErrorMessage'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  IErrorMessage.new(error_code: error_code,
                    error_message: error_message,
                    http_status_code: http_status_code,
                    detail_error_message: detail_error_message,
                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
# File 'lib/verizon/models/i_error_message.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['error_code'] = 'errorCode'
  @_hash['error_message'] = 'errorMessage'
  @_hash['http_status_code'] = 'httpStatusCode'
  @_hash['detail_error_message'] = 'detailErrorMessage'
  @_hash
end

.nullablesObject

An array for nullable fields



49
50
51
# File 'lib/verizon/models/i_error_message.rb', line 49

def self.nullables
  []
end

.optionalsObject

An array for optional fields



39
40
41
42
43
44
45
46
# File 'lib/verizon/models/i_error_message.rb', line 39

def self.optionals
  %w[
    error_code
    error_message
    http_status_code
    detail_error_message
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



102
103
104
105
106
107
108
# File 'lib/verizon/models/i_error_message.rb', line 102

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} error_code: #{@error_code.inspect}, error_message:"\
  " #{@error_message.inspect}, http_status_code: #{@http_status_code.inspect},"\
  " detail_error_message: #{@detail_error_message.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



94
95
96
97
98
99
# File 'lib/verizon/models/i_error_message.rb', line 94

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} error_code: #{@error_code}, error_message: #{@error_message},"\
  " http_status_code: #{@http_status_code}, detail_error_message: #{@detail_error_message},"\
  " additional_properties: #{@additional_properties}>"
end