Class: HermesAPI::CreationError

Inherits:
ActiveResource::ConnectionError
  • Object
show all
Defined in:
lib/hermes_api/creation_error.rb

Instance Method Summary collapse

Instance Method Details

#codeObject Also known as: codes



7
8
9
10
11
12
13
14
15
# File 'lib/hermes_api/creation_error.rb', line 7

def code
  if entries.is_a? Array
    entries.map do |entry|
      entry.dig("errorMessages", "errorCode")
    end
  else
    entries.dig("errorMessages", "errorCode")
  end
end

#code_with_descriptionsObject



25
26
27
28
29
30
31
32
33
# File 'lib/hermes_api/creation_error.rb', line 25

def code_with_descriptions
  if entries.is_a? Array
    entries.map do |entry|
      code = entry.dig("errorMessages", "errorCode")
      description = entry.dig("errorMessages", "errorDescription")
      "#{code}: #{description}"
    end
  end
end

#dataObject



3
4
5
# File 'lib/hermes_api/creation_error.rb', line 3

def data
  ActiveResource::Formats::XmlFormat.decode(@response.body)
end

#descriptionObject



19
20
21
22
23
# File 'lib/hermes_api/creation_error.rb', line 19

def description
  unless entries.is_a? Array
    entries.dig("errorMessages", "errorDescription")
  end
end

#to_sObject



35
36
37
38
39
40
41
# File 'lib/hermes_api/creation_error.rb', line 35

def to_s
  if entries.is_a? Array
    "#{code_with_descriptions.join(", ")}."
  else
    "#{code}: #{description}."
  end
end