Sha256: 78507d8da392b8cdb5499d6069d7e0a9c99bd39d2c4d3a1d211899e5ba3f874b

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

require 'dribbble/utils/findable'
require 'dribbble/bucket'
require 'dribbble/project'
require 'dribbble/shot'
require 'dribbble/team'

module Dribbble
  class User < Dribbble::Base
    include Dribbble::Utils::Findable

    def buckets(attrs = {})
      Dribbble::Bucket.batch_new token, html_get("/users/#{id}/buckets", attrs)
    end

    def followers(attrs = {})
      Dribbble::User.batch_new token, html_get("/users/#{id}/followers", attrs)
    end

    def following(attrs = {})
      Dribbble::User.batch_new token, html_get("/users/#{id}/following", attrs), 'followee'
    end

    def following?(other_user_id = nil)
      if other_user_id
        html_get "/users/#{id}/following/#{other_user_id}"
      else
        html_get "/user/following/#{id}"
      end
      true
    rescue RestClient::ResourceNotFound
      false
    end

    def follow!
      res = html_put "/users/#{id}/follow"
      res.code == 204 ? true : false
    end

    def unfollow!
      res = html_delete "/users/#{id}/follow"
      res.code == 204 ? true : false
    end

    def likes(attrs = {})
      Dribbble::Shot.batch_new token, html_get("/users/#{id}/likes", attrs), 'shot'
    end

    def projects(attrs = {})
      Dribbble::Project.batch_new token, html_get("/users/#{id}/projects", attrs)
    end

    def shots(attrs = {})
      Dribbble::Shot.batch_new token, html_get("/users/#{id}/shots", attrs)
    end

    def teams(attrs = {})
      Dribbble::Team.batch_new token, html_get("/users/#{id}/teams", attrs)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dribbble-1.0.0.beta1 lib/dribbble/user.rb