dropbox_api 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -12
  3. data/RELEASING.md +5 -0
  4. data/api_coverage.md +9 -0
  5. data/lib/dropbox_api.rb +23 -4
  6. data/lib/dropbox_api/chunked_uploader.rb +48 -0
  7. data/lib/dropbox_api/endpoints/content_upload.rb +16 -9
  8. data/lib/dropbox_api/endpoints/file_requests/create_file_request.rb +21 -0
  9. data/lib/dropbox_api/endpoints/files/get_metadata.rb +1 -1
  10. data/lib/dropbox_api/endpoints/files/get_thumbnail.rb +4 -4
  11. data/lib/dropbox_api/endpoints/files/get_thumbnail_batch.rb +38 -0
  12. data/lib/dropbox_api/endpoints/files/list_folder.rb +16 -1
  13. data/lib/dropbox_api/endpoints/files/list_folder_get_latest_cursor.rb +8 -9
  14. data/lib/dropbox_api/endpoints/files/list_folder_longpoll.rb +1 -1
  15. data/lib/dropbox_api/endpoints/files/list_revisions.rb +1 -1
  16. data/lib/dropbox_api/endpoints/files/move.rb +2 -2
  17. data/lib/dropbox_api/endpoints/files/save_url_check_job_status.rb +1 -1
  18. data/lib/dropbox_api/endpoints/files/search.rb +1 -1
  19. data/lib/dropbox_api/endpoints/files/upload.rb +17 -27
  20. data/lib/dropbox_api/endpoints/files/upload_session_append_v2.rb +7 -5
  21. data/lib/dropbox_api/endpoints/files/upload_session_finish.rb +5 -3
  22. data/lib/dropbox_api/endpoints/files/upload_session_start.rb +3 -3
  23. data/lib/dropbox_api/endpoints/rpc_content.rb +9 -0
  24. data/lib/dropbox_api/endpoints/sharing/add_file_member.rb +6 -6
  25. data/lib/dropbox_api/endpoints/sharing/add_folder_member.rb +5 -5
  26. data/lib/dropbox_api/endpoints/sharing/create_shared_link_with_settings.rb +2 -2
  27. data/lib/dropbox_api/endpoints/sharing/list_folder_members.rb +1 -1
  28. data/lib/dropbox_api/endpoints/sharing/list_shared_links.rb +1 -1
  29. data/lib/dropbox_api/endpoints/sharing/share_folder.rb +1 -1
  30. data/lib/dropbox_api/endpoints/virtual/upload_by_chunks.rb +49 -0
  31. data/lib/dropbox_api/errors/basic_error.rb +2 -0
  32. data/lib/dropbox_api/errors/create_file_request_error.rb +6 -0
  33. data/lib/dropbox_api/errors/thumbnail_batch_error.rb +7 -0
  34. data/lib/dropbox_api/errors/thumbnail_error.rb +10 -0
  35. data/lib/dropbox_api/metadata/access_level.rb +7 -4
  36. data/lib/dropbox_api/metadata/add_file_member_result.rb +13 -10
  37. data/lib/dropbox_api/metadata/add_member.rb +19 -16
  38. data/lib/dropbox_api/metadata/basic_account.rb +18 -15
  39. data/lib/dropbox_api/metadata/commit_info.rb +35 -1
  40. data/lib/dropbox_api/metadata/deleted.rb +9 -6
  41. data/lib/dropbox_api/metadata/file.rb +18 -15
  42. data/lib/dropbox_api/metadata/file_link_metadata.rb +48 -0
  43. data/lib/dropbox_api/metadata/file_member_action.rb +8 -5
  44. data/lib/dropbox_api/metadata/file_request.rb +30 -0
  45. data/lib/dropbox_api/metadata/folder.rb +9 -6
  46. data/lib/dropbox_api/metadata/{folder_link.rb → folder_link_metadata.rb} +1 -1
  47. data/lib/dropbox_api/metadata/folder_sharing_info.rb +7 -4
  48. data/lib/dropbox_api/metadata/link_permissions.rb +11 -8
  49. data/lib/dropbox_api/metadata/media_info.rb +14 -7
  50. data/lib/dropbox_api/metadata/media_metadata.rb +14 -12
  51. data/lib/dropbox_api/metadata/member.rb +12 -9
  52. data/lib/dropbox_api/metadata/member_action.rb +13 -10
  53. data/lib/dropbox_api/metadata/member_permission.rb +11 -8
  54. data/lib/dropbox_api/metadata/member_permission_list.rb +19 -17
  55. data/lib/dropbox_api/metadata/name.rb +9 -6
  56. data/lib/dropbox_api/metadata/photo_metadata.rb +14 -11
  57. data/lib/dropbox_api/metadata/resource.rb +1 -1
  58. data/lib/dropbox_api/metadata/shared_folder.rb +16 -13
  59. data/lib/dropbox_api/metadata/shared_folder_policy.rb +7 -4
  60. data/lib/dropbox_api/metadata/shared_link.rb +30 -18
  61. data/lib/dropbox_api/metadata/shared_link_metadata.rb +26 -0
  62. data/lib/dropbox_api/metadata/space_allocation.rb +7 -4
  63. data/lib/dropbox_api/metadata/space_usage.rb +9 -6
  64. data/lib/dropbox_api/metadata/{symbol.rb → tag.rb} +1 -1
  65. data/lib/dropbox_api/metadata/team_member_info.rb +11 -8
  66. data/lib/dropbox_api/metadata/thumbnail_batch_result_data.rb +6 -0
  67. data/lib/dropbox_api/metadata/thumbnail_batch_result_entry.rb +23 -0
  68. data/lib/dropbox_api/metadata/upload_session_cursor.rb +7 -4
  69. data/lib/dropbox_api/metadata/video_metadata.rb +15 -12
  70. data/lib/dropbox_api/metadata/write_mode.rb +3 -3
  71. data/lib/dropbox_api/{endpoints/options_validator.rb → options_validator.rb} +1 -1
  72. data/lib/dropbox_api/results/add_file_member_result_list.rb +1 -1
  73. data/lib/dropbox_api/results/get_thumbnail_batch_result.rb +9 -0
  74. data/lib/dropbox_api/results/list_shared_links_result.rb +1 -1
  75. data/lib/dropbox_api/version.rb +1 -1
  76. metadata +20 -6
  77. data/lib/dropbox_api/metadata/file_link.rb +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2801013459cdb9c5a71f72f07e5967cc09452625
4
- data.tar.gz: d99d873e573f87879f2b0acb8f215eda78ba5182
3
+ metadata.gz: 47cd12fc36b2c62e257a717af58a4a2fa11f802c
4
+ data.tar.gz: c1ae321423d2b7f2494bba5fa9e24870322b0b25
5
5
  SHA512:
6
- metadata.gz: c968a2f558de87f21e1428786ed34c021ffe092df8975f7904c93013a27a57a36f2f8bb0bc6e291cdaf8d7a025c7cd9b82637308ea49da88e1701b42ec0618f4
7
- data.tar.gz: a7659b676c8df3cd23df8679723d2716cd21bfd0280a3f1de6480a8c46fd769bc8d75d8adf7c6f9074dfc34caba3baba14563fe1dd07c9adf02d145872cfad72
6
+ metadata.gz: 11c9d49a540be98afedb19678fc4e85ac0de227eec0784916ce9279c9b37bba96922593a56096e56d058eb8b862c70684e827d292d60820f1fd5ee37f6f9c2e7
7
+ data.tar.gz: b75d171a9a4947d22f41efed6917e7e66b25636bf82fa2250b449978c0a0e6cf48868e1161a8292be7a1adbda4a0890b05cccdbb3f92e2a3f24af753b973caec
data/README.md CHANGED
@@ -116,7 +116,30 @@ result.has_more?
116
116
 
117
117
  The instance of `Client` we've initialized is the one you'll be using to
118
118
  perform API calls. You can check the class' documentation to find
119
- [all available endpoints](http://jesus.github.io/dropbox_api/DropboxApi/Client.html)
119
+ [all available endpoints](http://jesus.github.io/dropbox_api/DropboxApi/Client.html).
120
+
121
+ ### Large file uploads
122
+
123
+ If you need to upload files larger than 150MB the default `#upload` endpoint
124
+ won't work. Instead, you need to start a upload session and upload
125
+ the file in small chunks.
126
+
127
+ To make this easier, the method `upload_by_chunks` will handle this for you,
128
+ example:
129
+
130
+ ```ruby
131
+ client = DropboxApi::Client.new("VofXAX8D...")
132
+ #=> #<DropboxApi::Client ...>
133
+ File.open("large_file.avi") do |f|
134
+ client.upload_by_chunks "/remote_path.txt", f
135
+ end
136
+ ```
137
+
138
+ Check out the
139
+ [method documentation](http://www.xuuso.com/dropbox_api/DropboxApi/Client.html#upload_by_chunks-instance_method)
140
+ to find out all available options.
141
+
142
+
120
143
 
121
144
  ## Development
122
145
 
@@ -161,14 +184,3 @@ command line.
161
184
  Any help will be much appreciated. The easiest way to help is to implement one
162
185
  or more of the [endpoints that are still pending](http://jesus.github.io/dropbox_api/file.api_coverage.html). To see how the
163
186
  endpoints are implemented, check out the `lib/dropbox_api/endpoints` folder.
164
-
165
- If you want to help but you're unsure how to get started, please get in touch
166
- by opening an issue.
167
-
168
- Here's the standard way to submit code updates:
169
-
170
- 1. Fork it ( https://github.com/Jesus/dropbox_api/fork )
171
- 2. Create your feature branch (`git checkout -b my-new-feature`)
172
- 3. Commit your changes (`git commit -am 'Add some feature'`)
173
- 4. Push to the branch (`git push origin my-new-feature`)
174
- 5. Create a new Pull Request
@@ -0,0 +1,5 @@
1
+ 1. Bump version in `lib/dropbox_api/version.rb`.
2
+ 2. Tag a new release in Github, summarize the changes since the last release.
3
+ 3. Build gem: `gem build dropbox_api.gemspec`.
4
+ 4. Publish gem: `gem push dropbox_api-[...].gem`.
5
+ 5. Update documentation.
@@ -103,6 +103,15 @@ API call | Status
103
103
  `/get_current_account` | 🌕
104
104
  `/get_space_usage` | 🌕
105
105
 
106
+ ## File Requests namespace
107
+
108
+ API call | Status
109
+ --- | :---:
110
+ `/create` | 🌕
111
+ `/get` | 🌑
112
+ `/list` | 🌑
113
+ `/update` | 🌑
114
+
106
115
 
107
116
  ## Dropbox Business API
108
117
  Unfortunately, none of the Dropbox Business endpoints have been implemented.
@@ -12,7 +12,7 @@ require 'dropbox_api/middleware/stack'
12
12
  require 'dropbox_api/metadata/field'
13
13
  require 'dropbox_api/metadata/base'
14
14
 
15
- require 'dropbox_api/metadata/symbol'
15
+ require 'dropbox_api/metadata/tag'
16
16
  require 'dropbox_api/metadata/access_level'
17
17
  require 'dropbox_api/metadata/member_action'
18
18
 
@@ -42,14 +42,18 @@ require 'dropbox_api/metadata/deleted'
42
42
  require 'dropbox_api/metadata/resource'
43
43
  require 'dropbox_api/metadata/shared_folder_policy'
44
44
  require 'dropbox_api/metadata/shared_folder'
45
- require 'dropbox_api/metadata/file_link'
46
- require 'dropbox_api/metadata/folder_link'
45
+ require 'dropbox_api/metadata/file_link_metadata'
46
+ require 'dropbox_api/metadata/folder_link_metadata'
47
+ require 'dropbox_api/metadata/shared_link_metadata'
47
48
  require 'dropbox_api/metadata/shared_link'
48
49
  require 'dropbox_api/metadata/space_allocation'
49
50
  require 'dropbox_api/metadata/space_usage'
50
51
  require 'dropbox_api/metadata/upload_session_cursor'
51
52
  require 'dropbox_api/metadata/write_mode'
52
53
  require 'dropbox_api/metadata/commit_info'
54
+ require 'dropbox_api/metadata/thumbnail_batch_result_entry'
55
+ require 'dropbox_api/metadata/thumbnail_batch_result_data'
56
+ require 'dropbox_api/metadata/file_request'
53
57
 
54
58
  require 'dropbox_api/errors/http_error'
55
59
  require 'dropbox_api/errors/basic_error'
@@ -93,6 +97,9 @@ require 'dropbox_api/errors/add_file_member_error'
93
97
  require 'dropbox_api/errors/add_folder_member_error'
94
98
  require 'dropbox_api/errors/too_many_requests_error'
95
99
  require 'dropbox_api/errors/get_account_error'
100
+ require 'dropbox_api/errors/thumbnail_batch_error'
101
+ require 'dropbox_api/errors/thumbnail_error'
102
+ require 'dropbox_api/errors/create_file_request_error'
96
103
 
97
104
  require 'dropbox_api/result_builder'
98
105
  require 'dropbox_api/results/base'
@@ -101,6 +108,7 @@ require 'dropbox_api/results/get_copy_reference_result'
101
108
  require 'dropbox_api/results/save_copy_reference_result'
102
109
  require 'dropbox_api/results/add_file_member_result_list'
103
110
  require 'dropbox_api/results/get_temporary_link_result'
111
+ require 'dropbox_api/results/get_thumbnail_batch_result'
104
112
  require 'dropbox_api/results/list_folder_result'
105
113
  require 'dropbox_api/results/list_revisions_result'
106
114
  require 'dropbox_api/results/list_folder_longpoll_result'
@@ -117,13 +125,15 @@ require 'dropbox_api/results/upload_session_start'
117
125
 
118
126
  require 'dropbox_api/client'
119
127
  require 'dropbox_api/connection_builder'
128
+ require 'dropbox_api/options_validator'
120
129
 
121
130
  require 'dropbox_api/endpoints/base'
122
131
  require 'dropbox_api/endpoints/rpc'
132
+ require 'dropbox_api/endpoints/rpc_content'
123
133
  require 'dropbox_api/endpoints/rpc_notify'
124
134
  require 'dropbox_api/endpoints/content_download'
125
135
  require 'dropbox_api/endpoints/content_upload'
126
- require 'dropbox_api/endpoints/options_validator'
136
+
127
137
  require 'dropbox_api/endpoints/files/copy'
128
138
  require 'dropbox_api/endpoints/files/copy_reference_get'
129
139
  require 'dropbox_api/endpoints/files/copy_reference_save'
@@ -134,6 +144,7 @@ require 'dropbox_api/endpoints/files/get_metadata'
134
144
  require 'dropbox_api/endpoints/files/get_preview'
135
145
  require 'dropbox_api/endpoints/files/get_temporary_link'
136
146
  require 'dropbox_api/endpoints/files/get_thumbnail'
147
+ require 'dropbox_api/endpoints/files/get_thumbnail_batch'
137
148
  require 'dropbox_api/endpoints/files/list_folder'
138
149
  require 'dropbox_api/endpoints/files/list_folder_continue'
139
150
  require 'dropbox_api/endpoints/files/list_folder_longpoll'
@@ -148,6 +159,7 @@ require 'dropbox_api/endpoints/files/upload'
148
159
  require 'dropbox_api/endpoints/files/upload_session_start'
149
160
  require 'dropbox_api/endpoints/files/upload_session_append_v2'
150
161
  require 'dropbox_api/endpoints/files/upload_session_finish'
162
+
151
163
  require 'dropbox_api/endpoints/sharing/add_file_member'
152
164
  require 'dropbox_api/endpoints/sharing/add_folder_member'
153
165
  require 'dropbox_api/endpoints/sharing/list_folder_members'
@@ -155,7 +167,14 @@ require 'dropbox_api/endpoints/sharing/share_folder'
155
167
  require 'dropbox_api/endpoints/sharing/list_shared_links'
156
168
  require 'dropbox_api/endpoints/sharing/create_shared_link_with_settings'
157
169
  require 'dropbox_api/endpoints/sharing/unshare_file'
170
+
158
171
  require 'dropbox_api/endpoints/users/get_account'
159
172
  require 'dropbox_api/endpoints/users/get_account_batch'
160
173
  require 'dropbox_api/endpoints/users/get_current_account'
161
174
  require 'dropbox_api/endpoints/users/get_space_usage'
175
+
176
+ require 'dropbox_api/endpoints/file_requests/create_file_request'
177
+
178
+ require 'dropbox_api/chunked_uploader'
179
+
180
+ require 'dropbox_api/endpoints/virtual/upload_by_chunks'
@@ -0,0 +1,48 @@
1
+ module DropboxApi
2
+ class ChunkedUploader
3
+ include DropboxApi::OptionsValidator
4
+
5
+ def initialize(client, path, i_stream, options = {})
6
+ @chunk_size = options.delete(:chunk_size) || 4 * 1024 * 1024 # 4 MiB
7
+
8
+ @client = client
9
+ @i_stream = i_stream
10
+
11
+ init_commit_info(path, options)
12
+ end
13
+
14
+ def start
15
+ chunk = @i_stream.read @chunk_size
16
+
17
+ @cursor = @client.upload_session_start chunk
18
+ end
19
+
20
+ def upload
21
+ loop do
22
+ chunk = @i_stream.read @chunk_size
23
+ break if chunk.nil?
24
+
25
+ @client.upload_session_append_v2 @cursor, chunk
26
+ break if chunk.size < @chunk_size
27
+ end
28
+ end
29
+
30
+ def finish
31
+ @client.upload_session_finish @cursor, @commit_info
32
+ end
33
+
34
+ private
35
+
36
+ def init_commit_info(path, options)
37
+ validate_options([
38
+ :mode,
39
+ :autorename,
40
+ :client_modified,
41
+ :mute
42
+ ], options)
43
+
44
+ options[:path] = path
45
+ @commit_info = DropboxApi::Metadata::CommitInfo.build_from_options options
46
+ end
47
+ end
48
+ end
@@ -6,19 +6,14 @@ module DropboxApi::Endpoints
6
6
  end
7
7
  end
8
8
 
9
- def build_request(params, content)
10
- # TODO: It would be better to have a stream object on which we can call
11
- # #read, rather than the full file content.
12
- body = content
9
+ def build_request(params, body)
13
10
  headers = {
14
11
  'Dropbox-API-Arg' => JSON.dump(params),
15
12
  'Content-Type' => 'application/octet-stream'
16
13
  }
17
- if body.respond_to?(:length)
18
- headers['Content-Length'] = body.length.to_s
19
- elsif body.respond_to?(:stat)
20
- headers['Content-Length'] = body.stat.size.to_s
21
- end
14
+
15
+ content_length = get_content_length body
16
+ headers['Content-Length'] = content_length unless content_length.nil?
22
17
 
23
18
  return body, headers
24
19
  end
@@ -26,5 +21,17 @@ module DropboxApi::Endpoints
26
21
  def perform_request(params, content)
27
22
  process_response(get_response(params, content))
28
23
  end
24
+
25
+ private
26
+
27
+ def get_content_length(content)
28
+ if content.respond_to?(:bytesize)
29
+ content.bytesize.to_s
30
+ elsif content.respond_to?(:length)
31
+ content.length.to_s
32
+ elsif content.respond_to?(:stat)
33
+ content.stat.size.to_s
34
+ end
35
+ end
29
36
  end
30
37
  end
@@ -0,0 +1,21 @@
1
+ module DropboxApi::Endpoints::Files
2
+ class CreateFileRequest < DropboxApi::Endpoints::Rpc
3
+ Method = :post
4
+ Path = "/2/file_requests/create".freeze
5
+ ResultType = DropboxApi::Metadata::FileRequest
6
+ ErrorType = DropboxApi::Errors::CreateFileRequestError
7
+
8
+ # Create a file request for a given path.
9
+ #
10
+ # @param title [String] The title of the file request. Must not be empty.
11
+ # @param destination [String] The path of the folder in the Dropbox where
12
+ # uploaded files will be sent. For apps with the app folder permission,
13
+ # this will be relative to the app folder.
14
+ add_endpoint :create_file_request do |title, destination|
15
+ perform_request({
16
+ title: title,
17
+ destination: destination
18
+ })
19
+ end
20
+ end
21
+ end
@@ -5,7 +5,7 @@ module DropboxApi::Endpoints::Files
5
5
  ResultType = DropboxApi::Metadata::Resource
6
6
  ErrorType = DropboxApi::Errors::GetMetadataError
7
7
 
8
- include DropboxApi::Endpoints::OptionsValidator
8
+ include DropboxApi::OptionsValidator
9
9
 
10
10
  # Returns the metadata for a file or folder.
11
11
  #
@@ -5,7 +5,7 @@ module DropboxApi::Endpoints::Files
5
5
  ResultType = DropboxApi::Metadata::File
6
6
  ErrorType = DropboxApi::Errors::PreviewError
7
7
 
8
- include DropboxApi::Endpoints::OptionsValidator
8
+ include DropboxApi::OptionsValidator
9
9
 
10
10
  # Get a thumbnail for an image.
11
11
  #
@@ -39,11 +39,11 @@ module DropboxApi::Endpoints::Files
39
39
  # end
40
40
  # @param path [String] The path to the image file you want to thumbnail.
41
41
  # @option options format [:jpeg, :png] The format for the thumbnail image,
42
- # +:jpeg+ (default) or +:png+. For images that are photos, +:jpeg+ should be
42
+ # `:jpeg` (default) or `:png`. For images that are photos, `:jpeg` should be
43
43
  # preferred, while png is better for screenshots and digital arts. The
44
- # default is +:jpeg+.
44
+ # default is `:jpeg`.
45
45
  # @option options size [:w32h32, :w64h64, :w128h128, :w640h480, :w1024h768]
46
- # The size for the thumbnail image. The default is +:w64h64+.
46
+ # The size for the thumbnail image. The default is `:w64h64`.
47
47
  add_endpoint :get_thumbnail do |path, options = {}, &block|
48
48
  validate_options([:format, :size], options)
49
49
  options[:format] ||= :jpeg
@@ -0,0 +1,38 @@
1
+ module DropboxApi::Endpoints::Files
2
+ class GetThumbnailBatch < DropboxApi::Endpoints::RpcContent
3
+ Method = :post
4
+ Path = "/2/files/get_thumbnail_batch".freeze
5
+ ResultType = DropboxApi::Results::GetThumbnailBatchResult
6
+ ErrorType = DropboxApi::Errors::ThumbnailBatchError
7
+
8
+ include DropboxApi::OptionsValidator
9
+
10
+ # Get a thumbnails for a batch of images.
11
+ #
12
+ # @param paths [Array<String>] The paths to the image files you want thumbnails for.
13
+ # @option options format [:jpeg, :png] The format for the thumbnail image,
14
+ # `:jpeg` (default) or `:png`. For images that are photos, `:jpeg` should be
15
+ # preferred, while png is better for screenshots and digital arts. The
16
+ # default is `:jpeg`.
17
+ # @option options size [:w32h32, :w64h64, :w128h128, :w640h480, :w1024h768]
18
+ # The size for the thumbnail image. The default is `:w64h64`.
19
+ # @option options mode [:strict, :bestfit, :fitone_bestfit]
20
+ # How to resize and crop the image to achieve the desired size. The default
21
+ # for this union is strict.
22
+ add_endpoint :get_thumbnail_batch do |paths, options = {}|
23
+ validate_options([:format, :size, :mode], options)
24
+ options[:format] ||= :jpeg
25
+ options[:size] ||= :w64h64
26
+ options[:mode] ||= :strict
27
+
28
+ perform_request :entries => build_entries_params(paths, options)
29
+ end
30
+
31
+ def build_entries_params(paths, options)
32
+ paths.map do |path|
33
+ options.merge({ :path => path })
34
+ end
35
+ end
36
+
37
+ end
38
+ end
@@ -5,7 +5,7 @@ module DropboxApi::Endpoints::Files
5
5
  ResultType = DropboxApi::Results::ListFolderResult
6
6
  ErrorType = DropboxApi::Errors::ListFolderError
7
7
 
8
- include DropboxApi::Endpoints::OptionsValidator
8
+ include DropboxApi::OptionsValidator
9
9
 
10
10
  # Returns the contents of a folder.
11
11
  #
@@ -23,15 +23,30 @@ module DropboxApi::Endpoints::Files
23
23
  :recursive,
24
24
  :include_media_info,
25
25
  :include_deleted,
26
+ :shared_link,
26
27
  :include_has_explicit_shared_members
27
28
  ], options)
28
29
  options[:recursive] ||= false
29
30
  options[:include_media_info] ||= false
30
31
  options[:include_deleted] ||= false
32
+ options[:shared_link] = build_shared_link_param(options[:shared_link]) if options[:shared_link]
31
33
 
32
34
  perform_request options.merge({
33
35
  :path => path
34
36
  })
35
37
  end
38
+
39
+ private
40
+
41
+ def build_shared_link_param(shared_link_param)
42
+ case shared_link_param
43
+ when String, Symbol
44
+ DropboxApi::Metadata::SharedLink.new shared_link_param
45
+ when DropboxApi::Metadata::SharedLink
46
+ shared_link_param
47
+ else
48
+ raise ArgumentError, "Invalid `shared_link`: #{shared_link.inspect}"
49
+ end.to_hash
50
+ end
36
51
  end
37
52
  end
@@ -5,7 +5,7 @@ module DropboxApi::Endpoints::Files
5
5
  ResultType = DropboxApi::Results::ListFolderGetLatestCursorResult
6
6
  ErrorType = DropboxApi::Errors::ListFolderError
7
7
 
8
- include DropboxApi::Endpoints::OptionsValidator
8
+ include DropboxApi::OptionsValidator
9
9
 
10
10
  # A way to quickly get a cursor for the folder's state. Unlike
11
11
  # {DropboxApi::API#list_folder}, this doesn't return any entries. This
@@ -14,17 +14,16 @@ module DropboxApi::Endpoints::Files
14
14
  # Dropbox.
15
15
  #
16
16
  # @option options path [String] The path to the folder you want to read.
17
- # @option options recursive [Boolean] If +true+, the list folder operation
17
+ # @option options recursive [Boolean] If `true`, the list folder operation
18
18
  # will be applied recursively to all subfolders and the response will
19
19
  # contain contents of all subfolders. The default for this field is
20
- # +false+.
21
- # @option options include_media_info [Boolean] If +true+,
22
- # +FileMetadata.media_info+ is set for photo and video. The default for
23
- # this field is +false+.
24
- # @option options include_deleted [Boolean] If +true+,
25
- # {DropboxApi::Metadata::DeletedMetadata} will be returned for deleted
20
+ # `false`.
21
+ # @option options include_media_info [Boolean] If `true`, `media_info` is
22
+ # set for photo and video. The default for this field is `false`.
23
+ # @option options include_deleted [Boolean] If `true`,
24
+ # {DropboxApi::Metadata::Deleted} will be returned for deleted
26
25
  # file or folder, otherwise {DropboxApi::Errors::LookupError} will be
27
- # returned. The default for this field is +false+.
26
+ # returned. The default for this field is `false`.
28
27
  add_endpoint :list_folder_get_latest_cursor do |options = {}|
29
28
  validate_options([
30
29
  :path,
@@ -5,7 +5,7 @@ module DropboxApi::Endpoints::Files
5
5
  ResultType = DropboxApi::Results::ListFolderLongpollResult
6
6
  ErrorType = DropboxApi::Errors::ListFolderLongpollError
7
7
 
8
- include DropboxApi::Endpoints::OptionsValidator
8
+ include DropboxApi::OptionsValidator
9
9
 
10
10
  # A longpoll endpoint to wait for changes on an account. In conjunction
11
11
  # with list_folder, this call gives you a low-latency way to monitor an