class Ivapi::Error

Public Class Methods

from_response(response) click to toggle source

Returns the appropriate Ivapi::Error sublcass based on status and response message.

response - The Hash of HTTP response.

Returns the Ivapi::Error.

# File lib/ivapi/error.rb, line 11
def self.from_response(response)
  status = response[:status].to_i

  klass = case status
  when 400 then Ivapi::BadRequest
  when 401 then Ivapi::Unauthorized
  when 403 then Ivapi::Forbidden
  end

  klass&.new(response)
end