Sha256: 3f233e881355d45ca24638182cf78fd9229616fdf41df59ca924047ffbccb5a6

Contents?: true

Size: 961 Bytes

Versions: 2

Compression:

Stored size: 961 Bytes

Contents

require 'dribbble/utils/findable'
require 'dribbble/utils/creatable'
require 'dribbble/utils/updatable'
require 'dribbble/utils/deletable'

module Dribbble
  class Bucket < Dribbble::Base
    include Dribbble::Utils::Findable
    include Dribbble::Utils::Creatable
    include Dribbble::Utils::Updatable
    include Dribbble::Utils::Deletable

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

    def add_shot(shot)
      shot_id = shot.is_a?(Dribbble::Shot) ? shot.id : shot
      res = html_put("/buckets/#{id}/shots") do |payload|
        payload[:shot_id] = shot_id
      end
      res.code == 204 ? true : false
    end

    def remove_shot(shot)
      shot_id = shot.is_a?(Dribbble::Shot) ? shot.id : shot
      res = html_delete "/buckets/#{id}/shots", shot_id: shot_id
      res.code == 204 ? true : false
    end

    def self.available_fields
      %i(name description)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dribbble-1.0.0.beta2 lib/dribbble/bucket.rb
dribbble-1.0.0.beta1 lib/dribbble/bucket.rb