Class: Elements::ErrorDetails

Inherits:
ElementsObject show all
Defined in:
lib/elements/errors.rb

Overview

Contains the detail error information received from the Elements API, refer to elements-pay.readme.io/reference/errors for more information.

Constant Summary

Constants inherited from ElementsObject

Elements::ElementsObject::PERMANENT_ATTRIBUTES, Elements::ElementsObject::RESERVED_FIELD_NAMES

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ElementsObject

#[], #as_json, #initialize, #to_json

Constructor Details

This class inherits a constructor from Elements::ElementsObject

Class Method Details

.from_http_body(body) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/elements/errors.rb', line 35

def self.from_http_body(body)
  return nil if body.nil?

  json_body = JSON.parse(body, symbolize_names: true)
  return nil unless json_body.key?(:error)

  error = json_body[:error]
  Util.convert_to_elements_object(error)
rescue JSON::ParserError
  nil
end

Instance Method Details

#codeObject



11
12
13
# File 'lib/elements/errors.rb', line 11

def code
  @attributes[:code]
end

#decline_codeObject



31
32
33
# File 'lib/elements/errors.rb', line 31

def decline_code
  @attributes[:decline_code]
end

#messageObject



15
16
17
# File 'lib/elements/errors.rb', line 15

def message
  @attributes[:message]
end

#paramObject



27
28
29
# File 'lib/elements/errors.rb', line 27

def param
  @attributes[:param]
end

#psp_referenceObject



23
24
25
# File 'lib/elements/errors.rb', line 23

def psp_reference
  @attributes[:psp_reference]
end

#trace_idObject



19
20
21
# File 'lib/elements/errors.rb', line 19

def trace_id
  @attributes[:trace_id]
end

#typeObject



7
8
9
# File 'lib/elements/errors.rb', line 7

def type
  @attributes[:type]
end