Class: DropboxApi::Endpoints::Sharing::ShareFolder

Inherits:
Rpc
  • Object
show all
Includes:
OptionsValidator
Defined in:
lib/dropbox_api/endpoints/sharing/share_folder.rb

Constant Summary collapse

Method =
:post
Path =
"/2/sharing/share_folder".freeze
ResultType =
DropboxApi::Results::ShareFolderLaunch
ErrorType =
DropboxApi::Errors::ShareFolderError

Instance Method Summary collapse

Methods included from OptionsValidator

#validate_options

Methods inherited from Rpc

#build_request, #initialize

Methods inherited from Base

add_endpoint

Constructor Details

This class inherits a constructor from DropboxApi::Endpoints::Rpc

Instance Method Details

#share_folder(path, options = {}) ⇒ ShareFolderLaunch

Share a folder with collaborators.

Most sharing will be completed synchronously. Large folders will be completed asynchronously. To make testing the async case repeatable, set ‘ShareFolderArg.force_async`.

If a ShareFolderLaunch.async_job_id is returned, you’ll need to call check_share_job_status until the action completes to get the metadata for the folder.

Apps must have full Dropbox access to use this endpoint.

Parameters:

  • path (String)

    The path to the folder to share. If it does not exist, then a new one is created.

Returns:

  • (ShareFolderLaunch)

    Shared folder metadata.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/dropbox_api/endpoints/sharing/share_folder.rb', line 37

add_endpoint :share_folder do |path, options = {}|
  validate_options([
    :member_policy,
    :acl_update_policy,
    :shared_link_policy,
    :force_async
  ], options)
  options[:member_policy] ||= :anyone
  options[:acl_update_policy] ||= :owner
  options[:shared_link_policy] ||= :anyone
  options[:force_async] ||= false

  begin
    perform_request options.merge({
      :path => path
    })
  rescue DropboxApi::Errors::AlreadySharedError => error
    error.shared_folder
  end
end