lib/alma/response.rb in alma-0.5.1 vs lib/alma/response.rb in alma-0.6.0

- old
+ new

@@ -12,11 +12,11 @@ attr_reader :raw_response def_delegators :raw_response, :body, :success?, :response, :request def initialize(response) @raw_response = response - # We could validate and throw an error here but currently a + @response = response.parsed_response validate(response) end def loggable { uri: @raw_response&.request&.uri.to_s @@ -35,11 +35,23 @@ log = loggable.merge(response.parsed_response) raise StandardError.new("Invalid Response.", log) end end + def request_id + @response.fetch("request_id", "") + end + + def managed_by_library + @response.fetch("managed_by_library", "") + end + + def managed_by_library_code + @response.fetch("managed_by_library_code", "") + end + # Returns an array of errors def errors - @raw_response.parsed_response&.dig("errorList", "error") || [] + @response&.dig("errorList", "error") || [] end end end