Class: HermesAPI::CreationError
- Inherits:
-
ActiveResource::ConnectionError
- Object
- ActiveResource::ConnectionError
- HermesAPI::CreationError
- Defined in:
- lib/hermes_api/creation_error.rb
Instance Method Summary collapse
- #code ⇒ Object (also: #codes)
- #code_with_descriptions ⇒ Object
- #data ⇒ Object
- #description ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#code ⇒ Object 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_descriptions ⇒ Object
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 |
#data ⇒ Object
3 4 5 |
# File 'lib/hermes_api/creation_error.rb', line 3 def data ActiveResource::Formats::XmlFormat.decode(@response.body) end |
#description ⇒ Object
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_s ⇒ Object
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 |