Module: Dropbox::WebClient::Actions

Included in:
Session
Defined in:
lib/dropbox/web_client/actions.rb

Instance Method Summary collapse

Instance Method Details

#invite(path, emails, message = "", is_shared_folder = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dropbox/web_client/actions.rb', line 5

def invite(path, emails, message = "", is_shared_folder = nil)
  ensure_authenticated
  
  if is_shared_folder.nil?
    # Determine if the folder exists
    share_options_response = share_options(path)
    
    is_shared_folder = !share_options_response.error?
  end

  params = {
    "emails" => emails.join(","),
    "custom_message" => message,
    "t" => cookies.,
    "_subject_uid" => subject_uid
  }
  if is_shared_folder
    url = invite_more_url
    params["ns_id"] = share_options(path).response_data[:ns_id]
  else
    url = invite_url
    params["path"] = path
  end

  response = RestClient.post(url, params, {:cookies => cookies.all})
  response_text = response.body

  return ResponseParser.new(response_text)
end

#share_options(path) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/dropbox/web_client/actions.rb', line 35

def share_options(path)
  ensure_authenticated
  url = share_options_url(:path => path)

  response = RestClient.post(url, {
    "t" => cookies.,
    "_subject_uid" => subject_uid
  }, {:cookies => cookies.for_share_options})

  return ResponseParser.new(response.body, :share_options)
end