module Dirigible::Utils
@private
Public Class Methods
handle_api_error(response)
click to toggle source
# File lib/dirigible/utils.rb, line 4 def self.handle_api_error(response) message = parse_message(response) klass = case response.status when 400 then BadRequest when 401 then Unauthorized when 404 then NotFound when 405 then MethodNotAllowed when 406 then NotAcceptable when 503 then ServiceUnavailable else Error end raise klass.new(message) end
parse_json(json)
click to toggle source
# File lib/dirigible/utils.rb, line 20 def self.parse_json(json) MultiJson.load(json, symbolize_keys: true) end
parse_message(response)
click to toggle source
# File lib/dirigible/utils.rb, line 24 def self.parse_message(response) begin parse_json(response.body) rescue response.body end end