class Clever::Response

Attributes

body[RW]
next_uri[R]
raw_body[R]
self_uri[R]
status[R]

Public Class Methods

new(faraday_response) click to toggle source
# File lib/clever/response.rb, line 9
def initialize(faraday_response)
  @status   = faraday_response.status
  @raw_body = faraday_response.body

  return unless faraday_response.body

  @body     = faraday_response.body['data']
  @links    = faraday_response.body['links']

  uri(:self)
  uri(:next)
end

Public Instance Methods

success?() click to toggle source
# File lib/clever/response.rb, line 22
def success?
  @status == 200
end

Private Instance Methods

uri(kind) click to toggle source
# File lib/clever/response.rb, line 28
def uri(kind)
  return unless @links

  object = @links.find { |link| link['rel'] == kind.to_s }

  return unless object

  instance_variable_set("@#{kind}_uri", object['uri'])
end