         console.log res
         if res['result']
           console.log res.result
-          @$progress.create_bucket_success(res.result)
+          @hook.create_bucket_success(res.result)
         else
-          @$progress.error(res.error)
+          @hook.error(res.error)
 
-  add_to_bucket: (resource_type, resource_id, bucket_type, bucket_id) ->
+  _add_to_bucket: (resource_type, resource_id, bucket_type, bucket_id) ->
     jQuery.ajax
       url: @bucketings_path
       method: "POST"

class @MindpinBuckets
  constructor: (@$path_fix, @$progress)->
    @_init()

  _init: ->
    if !@$path_fix
      @$path_fix = ""
    @buckets_path = @$path_fix + "/buckets"
    @bucketings_path = @$path_fix + "/bucketings"
    @$progress ||= new MindpinBucketsAdapter(@)

  buckets: (bucket_type, resource_type, resource_id) ->
    jQuery.ajax
      url: "#{@buckets_path}?bucket_type=#{bucket_type}&resource_type=#{resource_type}&resource_id=#{resource_id}"
      method: "GET"
      success: (res) =>
        console.log "buckets success"
        console.log res
        if res['result']
          @$progress.get_buckets_success(res.result)
        else
          @$progress.error(res.error)

  create_bucket: (bucket_type, name, desc) ->
    jQuery.ajax
      url: @buckets_path
      method: "POST"

        console.log res
        if res['result']
          console.log res.result
          @hook.remove_from_bucket_success(res.result)
        else
          @hook.error(res.error)

  buckets: (bucket_type, resource_type, resource_id) ->
    jQuery.ajax
      url: "#{@buckets_path}?bucket_type=#{bucket_type}&resource_type=#{resource_type}&resource_id=#{resource_id}"
      method: "GET"
      success: (res) =>
        console.log "buckets success"
        console.log res
        if res['result']
          @hook.buckets_success(res.result)
        else
          @hook.error(res.error)


  remove_from_bucket: (bucket_id) ->
    console.log 'fm remove from bucket'
    @_remove_from_bucket(@resource_type, @resource_id, @bucket_type, bucket_id)

  create_bucket: (bucket_name, bucket_desc) ->
    console.log 'create bucket'
    @_create_bucket(@bucket_type, bucket_name, bucket_desc)

  add_to_bucket: (bucket_id) ->
    console.log 'add to bucket'
    @_add_to_bucket(@resource_type, @resource_id, @bucket_type, bucket_id)
