Sha256: a295c625cb2fb2b2fd3f43b618a2703f40d11af82cb832ca13dc2653874e6105

Contents?: true

Size: 540 Bytes

Versions: 1

Compression:

Stored size: 540 Bytes

Contents

module Dailycred
  class Response
    require 'json'
    attr_accessor :json, :body, :headers, :status

    def initialize response
      @body = response.body
      @json = JSON.parse(@body)
      @headers = response.headers
      @status = response.status
    end

    def errors?
      json["worked"] != true
    end

    def success?
      @status == 200 && json["worked"] == true
    end

    def errors
      begin
        json["errors"][0]
      rescue
        nil
      end
    end

    def user
      json["user"]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dailycred-0.3.1 lib/dailycred/response.rb