class Response

Attributes

content[RW]

Public Class Methods

new(http_response) click to toggle source
# File lib/response.rb, line 5
def initialize(http_response)
  @status = http_response.response.code
  @content = parse_contents(http_response)
end

Public Instance Methods

rate_limited?() click to toggle source
# File lib/response.rb, line 10
def rate_limited?
  @status == "429"
end
success?() click to toggle source
# File lib/response.rb, line 14
def success?
  @status == "200" && !@content.nil?
end

Private Instance Methods

parse_contents(response) click to toggle source
# File lib/response.rb, line 20
def parse_contents(response)
  stringify_response = response.to_s
  json_object = JSON.parse(stringify_response, :symbolize_names => true)
  json_object[:contents]
end