Class: DropboxApi::Endpoints::Sharing::CreateSharedLinkWithSettings

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

Constant Summary collapse

Method =
:post
Path =
"/2/sharing/create_shared_link_with_settings".freeze
ResultType =
DropboxApi::Metadata::SharedLinkMetadata
ErrorType =
DropboxApi::Errors::CreateSharedLinkWithSettingsError

Instance Method Summary collapse

Methods included from OptionsValidator

#validate_options

Methods inherited from Rpc

#build_request, #initialize, #request_body

Methods inherited from Base

add_endpoint

Constructor Details

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

Instance Method Details

Create a shared link with custom settings. If no settings are given then the default visibility is :public. (The resolved visibility, though, may depend on other aspects such as team and shared folder settings).

NOTE: The settings parameter will only work for pro, business or enterprise accounts. It will return no permission error otherwise.

Parameters:

  • path (String)

    The path to be shared by the shared link.

  • settings (SharedLinkSettings) (defaults to: {})

    The requested settings for the newly created shared link This field is optional.

Options Hash (settings):

  • requested_visibility (Object)

    The requested access for this shared link. This field is optional. Must be one of "public", "team_only" or "password".

  • link_password (Object)

    If requested_visibility is "password" this is needed to specify the password to access the link. This field is optional.

  • expires (Object)

    Expiration time of the shared link. By default the link won't expire. This field is optional.

Returns:


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/dropbox_api/endpoints/sharing/create_shared_link_with_settings.rb', line 31

add_endpoint :create_shared_link_with_settings do |path, settings = {}|
  validate_options([
    :requested_visibility,
    :link_password,
    :expires
  ], settings)
  settings[:requested_visibility] ||= 'public'
  settings[:link_password] ||= nil
  settings[:expires] ||= nil

  perform_request({
    :path => path,
    :settings => settings
  })
end