class Rubychy::ApiResponse
Attributes
body[R]
result[R]
success[R]
success?[R]
Public Class Methods
new(response,fail_silently = false)
click to toggle source
# File lib/rubychy/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 Rubychy::Errors::BadRequestError.new(data['error'], data['message']) end end else if !fail_silently fail Rubychy::Errors::ServiceUnavailableError.new(response.status) end end end
parse(request)
click to toggle source
# File lib/rubychy/api_response.rb, line 27 def self.parse(request) Rubychy::DataTypes::ReceivedMessages.new(MultiJson.load(request.body)) end