class Fabychy::ApiResponse
Attributes
body[R]
result[R]
success[R]
success?[R]
Public Class Methods
new(response,fail_silently = false)
click to toggle source
# File lib/fabychy/api_response.rb, line 7 def initialize(response,fail_silently = false) if response.status < 500 @body = response.body data = MultiJson.load(@body) @success = (response.status == 200) if @success @result = data else if !fail_silently fail Fabychy::Errors::BadRequestError.new(data['error'], data['message']) end end else if !fail_silently fail Fabychy::Errors::ServiceUnavailableError.new(response.status) end end end
parse(request)
click to toggle source
# File lib/fabychy/api_response.rb, line 27 def self.parse(request) MultiJson.load(request.body) end