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
@@ -1,23 +1,26 @@
1
1
  module DropboxApi::Metadata
2
2
  # Examples of serialized {AddMember} objects:
3
- # {
4
- # "member": {
5
- # ".tag": "email",
6
- # "email": "justin@example.com"
7
- # },
8
- # "access_level": {
9
- # ".tag": "editor"
10
- # }
3
+ #
4
+ # ```json
5
+ # {
6
+ # "member": {
7
+ # ".tag": "email",
8
+ # "email": "justin@example.com"
11
9
  # },
12
- # {
13
- # "member": {
14
- # ".tag": "dropbox_id",
15
- # "dropbox_id": "dbid:AAEufNrMPSPe0dMQijRP0N_aZtBJRm26W4Q"
16
- # },
17
- # "access_level": {
18
- # ".tag": "viewer"
19
- # }
10
+ # "access_level": {
11
+ # ".tag": "editor"
20
12
  # }
13
+ # },
14
+ # {
15
+ # "member": {
16
+ # ".tag": "dropbox_id",
17
+ # "dropbox_id": "dbid:AAEufNrMPSPe0dMQijRP0N_aZtBJRm26W4Q"
18
+ # },
19
+ # "access_level": {
20
+ # ".tag": "viewer"
21
+ # }
22
+ # }
23
+ # ```
21
24
  class AddMember < Base
22
25
  class << self
23
26
  def build_from_string(member, access_level = :editor)
@@ -1,20 +1,23 @@
1
1
  module DropboxApi::Metadata
2
2
  # Example of a serialized {BasicAccount} object:
3
- # {
4
- # "account_id": "dbid:AAH4f99T0taONIb-OurWxbNQ6ywGRopQngc",
5
- # "name": {
6
- # "given_name": "Franz",
7
- # "surname": "Ferdinand",
8
- # "familiar_name": "Franz",
9
- # "display_name": "Franz Ferdinand (Personal)"
10
- # },
11
- # "email": "franz@dropbox.com",
12
- # "email_verified": true,
13
- # "disabled": false,
14
- # "is_teammate": true,
15
- # "profile_photo_url": "https://dl-web.dropbox.com/account_photo/get/dbid%3AAAH4f99T0taONIb-OurWxbNQ6ywGRopQngc?vers=1453416696524&size=128x128",
16
- # "team_member_id": "dbmid:AAHhy7WsR0x-u4ZCqiDl5Fz5zvuL3kmspwU"
17
- # }
3
+ #
4
+ # ```json
5
+ # {
6
+ # "account_id": "dbid:AAH4f99T0taONIb-OurWxbNQ6ywGRopQngc",
7
+ # "name": {
8
+ # "given_name": "Franz",
9
+ # "surname": "Ferdinand",
10
+ # "familiar_name": "Franz",
11
+ # "display_name": "Franz Ferdinand (Personal)"
12
+ # },
13
+ # "email": "franz@dropbox.com",
14
+ # "email_verified": true,
15
+ # "disabled": false,
16
+ # "is_teammate": true,
17
+ # "profile_photo_url": "https://dl-web.dropbox.com/account_photo/get/dbid%3AAAH4f99T0taONIb-OurWxbNQ6ywGRopQngc?vers=1453416696524&size=128x128",
18
+ # "team_member_id": "dbmid:AAHhy7WsR0x-u4ZCqiDl5Fz5zvuL3kmspwU"
19
+ # }
20
+ # ```
18
21
  class BasicAccount < Base
19
22
  field :account_id, String
20
23
  field :name, DropboxApi::Metadata::Name
@@ -1,9 +1,43 @@
1
1
  module DropboxApi::Metadata
2
2
  class CommitInfo < Base
3
3
  field :path, String
4
- field :mode, DropboxApi::Metadata::WriteMode
4
+ field :mode, DropboxApi::Metadata::WriteMode, :optional
5
5
  field :autorename, :boolean, :optional
6
6
  field :client_modified, Time, :optional
7
7
  field :mute, :boolean, :optional
8
+
9
+ class << self
10
+ def build_from_options(options)
11
+ options = Hash[options.map do |key, value|
12
+ case key
13
+ when :mode
14
+ [key.to_s, build_write_mode(value)]
15
+ when :client_modified
16
+ [key.to_s, build_client_modified(value)]
17
+ when :path, :autorename, :mute
18
+ [key.to_s, value]
19
+ end
20
+ end.compact]
21
+
22
+ new(options)
23
+ end
24
+
25
+ private
26
+
27
+ def build_write_mode(write_mode)
28
+ case write_mode
29
+ when String, Symbol
30
+ DropboxApi::Metadata::WriteMode.new write_mode
31
+ when DropboxApi::Metadata::WriteMode
32
+ write_mode
33
+ else
34
+ raise ArgumentError, "Invalid write mode: #{write_mode.inspect}"
35
+ end.to_hash
36
+ end
37
+
38
+ def build_client_modified(client_modified)
39
+ client_modified.utc.strftime("%FT%TZ")
40
+ end
41
+ end
8
42
  end
9
43
  end
@@ -1,11 +1,14 @@
1
1
  module DropboxApi::Metadata
2
2
  # Example of a serialized {Deleted} object:
3
- # {
4
- # ".tag": "deleted",
5
- # "name": "file.txt",
6
- # "path_lower": "/file.txt",
7
- # "path_display": "/file.txt"
8
- # }
3
+ #
4
+ # ```json
5
+ # {
6
+ # ".tag": "deleted",
7
+ # "name": "file.txt",
8
+ # "path_lower": "/file.txt",
9
+ # "path_display": "/file.txt"
10
+ # }
11
+ # ```
9
12
  class Deleted < Base
10
13
  field :name, String
11
14
  field :path_lower, String
@@ -1,21 +1,24 @@
1
1
  module DropboxApi::Metadata
2
2
  # Example of a serialized {File} object:
3
- # {
4
- # ".tag": "file",
5
- # "name": "Prime_Numbers.txt",
6
- # "path_lower": "/homework/math/prime_numbers.txt",
7
- # "path_display": "/Homework/math/Prime_Numbers.txt",
8
- # "id": "id:a4ayc_80_OEAAAAAAAAAXw",
9
- # "client_modified": "2015-05-12T15:50:38Z",
10
- # "server_modified": "2015-05-12T15:50:38Z",
11
- # "rev": "a1c10ce0dd78",
12
- # "size": 7212,
13
- # "sharing_info": {
14
- # "read_only": true,
15
- # "parent_shared_folder_id": "84528192421",
16
- # "modified_by": "dbid:AAH4f99T0taONIb-OurWxbNQ6ywGRopQngc"
17
- # }
3
+ #
4
+ # ```json
5
+ # {
6
+ # ".tag": "file",
7
+ # "name": "Prime_Numbers.txt",
8
+ # "path_lower": "/homework/math/prime_numbers.txt",
9
+ # "path_display": "/Homework/math/Prime_Numbers.txt",
10
+ # "id": "id:a4ayc_80_OEAAAAAAAAAXw",
11
+ # "client_modified": "2015-05-12T15:50:38Z",
12
+ # "server_modified": "2015-05-12T15:50:38Z",
13
+ # "rev": "a1c10ce0dd78",
14
+ # "size": 7212,
15
+ # "sharing_info": {
16
+ # "read_only": true,
17
+ # "parent_shared_folder_id": "84528192421",
18
+ # "modified_by": "dbid:AAH4f99T0taONIb-OurWxbNQ6ywGRopQngc"
18
19
  # }
20
+ # }
21
+ # ```
19
22
  class File < Base
20
23
  field :name, String
21
24
  field :path_lower, String
@@ -0,0 +1,48 @@
1
+ module DropboxApi::Metadata
2
+ # Example of a serialized {FileLinkMetadata} object:
3
+ #
4
+ # ```json
5
+ # {
6
+ # ".tag": "file",
7
+ # "url": "https://www.dropbox.com/s/2sn712vy1ovegw8/Prime_Numbers.txt?dl=0",
8
+ # "name": "Prime_Numbers.txt",
9
+ # "link_permissions": {
10
+ # "can_revoke": false,
11
+ # "resolved_visibility": {
12
+ # ".tag": "public"
13
+ # },
14
+ # "revoke_failure_reason": {
15
+ # ".tag": "owner_only"
16
+ # }
17
+ # },
18
+ # "client_modified": "2015-05-12T15:50:38Z",
19
+ # "server_modified": "2015-05-12T15:50:38Z",
20
+ # "rev": "a1c10ce0dd78",
21
+ # "size": 7212,
22
+ # "id": "id:a4ayc_80_OEAAAAAAAAAXw",
23
+ # "path_lower": "/homework/math/prime_numbers.txt",
24
+ # "team_member_info": {
25
+ # "team_info": {
26
+ # "id": "dbtid:AAFdgehTzw7WlXhZJsbGCLePe8RvQGYDr-I",
27
+ # "name": "Acme, Inc."
28
+ # },
29
+ # "display_name": "Roger Rabbit",
30
+ # "member_id": "dbmid:abcd1234"
31
+ # }
32
+ # }
33
+ # ```
34
+ class FileLinkMetadata < Base
35
+ field :url, String
36
+ field :name, String
37
+ field :link_permissions, DropboxApi::Metadata::LinkPermissions
38
+ field :client_modified, Time
39
+ field :server_modified, Time
40
+ field :rev, String
41
+ field :size, Integer
42
+ field :id, String, :optional
43
+ field :expires, Time, :optional
44
+ field :path_lower, String, :optional
45
+ field :team_member_info, DropboxApi::Metadata::TeamMemberInfo, :optional
46
+ field :content_owner_team_info, DropboxApi::Metadata::Team, :optional
47
+ end
48
+ end
@@ -1,11 +1,14 @@
1
1
  module DropboxApi::Metadata
2
2
  # Example of a serialized FileMemberAction:
3
- # {
4
- # ".tag": "success",
5
- # "success": {
6
- # ".tag": "viewer"
7
- # }
3
+ #
4
+ # ```json
5
+ # {
6
+ # ".tag": "success",
7
+ # "success": {
8
+ # ".tag": "viewer"
8
9
  # }
10
+ # }
11
+ # ```
9
12
  class FileMemberAction < Base
10
13
  class << self
11
14
  def new(data)
@@ -0,0 +1,30 @@
1
+ module DropboxApi::Metadata
2
+ # Example of a serialized {FileRequest} object:
3
+ #
4
+ # ```json
5
+ # {
6
+ # "id": "oaCAVmEyrqYnkZX9955Y",
7
+ # "url": "https://www.dropbox.com/request/oaCAVmEyrqYnkZX9955Y",
8
+ # "title": "Homework submission",
9
+ # "created": "2015-10-05T17:00:00Z",
10
+ # "is_open": true,
11
+ # "file_count": 3,
12
+ # "destination": "/File Requests/Homework",
13
+ # "deadline": {
14
+ # "deadline": "2020-10-12T17:00:00Z",
15
+ # "allow_late_uploads": {
16
+ # ".tag": "seven_days"
17
+ # }
18
+ # }
19
+ # }
20
+ # ```
21
+ class FileRequest < Base
22
+ field :id, String
23
+ field :url, String
24
+ field :title, String
25
+ field :created, Time
26
+ field :is_open, :boolean
27
+ field :file_count, Integer
28
+ field :destination, String
29
+ end
30
+ end
@@ -1,11 +1,14 @@
1
1
  module DropboxApi::Metadata
2
2
  # Example of a serialized {Folder} object:
3
- # {
4
- # "name": "arizona_baby",
5
- # "path_lower": "/arizona_baby",
6
- # "path_display": "/arizona_baby",
7
- # "id": "id:7eWkV5hcfzAAAAAAAAAAAQ"
8
- # }
3
+ #
4
+ # ```json
5
+ # {
6
+ # "name": "arizona_baby",
7
+ # "path_lower": "/arizona_baby",
8
+ # "path_display": "/arizona_baby",
9
+ # "id": "id:7eWkV5hcfzAAAAAAAAAAAQ"
10
+ # }
11
+ # ```
9
12
  class Folder < Base
10
13
  field :name, String
11
14
  field :path_lower, String
@@ -1,5 +1,5 @@
1
1
  module DropboxApi::Metadata
2
- class FolderLink < Base
2
+ class FolderLinkMetadata < Base
3
3
  field :url, String
4
4
  field :name, String
5
5
  field :link_permissions, DropboxApi::Metadata::LinkPermissions
@@ -1,9 +1,12 @@
1
1
  module DropboxApi::Metadata
2
2
  # Example of a serialized {FolderSharingInfo} object:
3
- # {
4
- # "read_only": false,
5
- # "parent_shared_folder_id": "84528192421"
6
- # }
3
+ #
4
+ # ```json
5
+ # {
6
+ # "read_only": false,
7
+ # "parent_shared_folder_id": "84528192421"
8
+ # }
9
+ # ```
7
10
  class FolderSharingInfo < Base
8
11
  field :read_only, :boolean
9
12
  field :parent_shared_folder_id, String, :optional
@@ -1,14 +1,17 @@
1
1
  module DropboxApi::Metadata
2
2
  # Example of a serialized {LinkPermissions} object:
3
- # {
4
- # "can_revoke": false,
5
- # "resolved_visibility": {
6
- # ".tag": "public"
7
- # },
8
- # "revoke_failure_reason": {
9
- # ".tag": "owner_only"
10
- # }
3
+ #
4
+ # ```json
5
+ # {
6
+ # "can_revoke": false,
7
+ # "resolved_visibility": {
8
+ # ".tag": "public"
9
+ # },
10
+ # "revoke_failure_reason": {
11
+ # ".tag": "owner_only"
11
12
  # }
13
+ # }
14
+ # ```
12
15
  class LinkPermissions < Base
13
16
  field :can_revoke, :boolean
14
17
  field :resolved_visibility, Symbol, :optional
@@ -1,13 +1,20 @@
1
1
  module DropboxApi::Metadata
2
2
  # Example of a serialized {MediaInfo} object:
3
- # {
4
- # ".tag": "metadata",
5
- # "metadata": {...}
6
- # }
3
+ #
4
+ # ```json
5
+ # {
6
+ # ".tag": "metadata",
7
+ # "metadata": {...}
8
+ # }
9
+ # ```
10
+ #
7
11
  # or:
8
- # {
9
- # ".tag": "pending"
10
- # }
12
+ #
13
+ # ```json
14
+ # {
15
+ # ".tag": "pending"
16
+ # }
17
+ # ```
11
18
  class MediaInfo < Base
12
19
  class << self
13
20
  def new(data)
@@ -1,19 +1,21 @@
1
1
  module DropboxApi::Metadata
2
2
  # Example of a serialized {MediaInfo} object:
3
- # {
4
- # ".tag": "video",
5
- # "dimensions": {
6
- # "height": 1500,
7
- # "width": 1500
8
- # },
9
- # "location": {
10
- # "latitude": 10.123456,
11
- # "longitude": 5.123456
12
- # }
13
- # "time_taken": "2016-09-04T17:00:27Z",
14
- # "duration": 6000
3
+ #
4
+ # ```json
5
+ # {
6
+ # ".tag": "video",
7
+ # "dimensions": {
8
+ # "height": 1500,
9
+ # "width": 1500
10
+ # },
11
+ # "location": {
12
+ # "latitude": 10.123456,
13
+ # "longitude": 5.123456
15
14
  # }
15
+ # "time_taken": "2016-09-04T17:00:27Z",
16
+ # "duration": 6000
16
17
  # }
18
+ # ```
17
19
  class MediaMetadata < Base
18
20
  class << self
19
21
  def new(data)
@@ -1,14 +1,17 @@
1
1
  module DropboxApi::Metadata
2
2
  # Examples of serialized {AddMember} objects:
3
- # [
4
- # {
5
- # ".tag": "email",
6
- # "email": "justin@example.com"
7
- # }, {
8
- # ".tag": "dropbox_id",
9
- # "dropbox_id": "dbid:AAEufNrMPSPe0dMQijRP0N_aZtBJRm26W4Q"
10
- # }
11
- # ]
3
+ #
4
+ # ```json
5
+ # [
6
+ # {
7
+ # ".tag": "email",
8
+ # "email": "justin@example.com"
9
+ # }, {
10
+ # ".tag": "dropbox_id",
11
+ # "dropbox_id": "dbid:AAEufNrMPSPe0dMQijRP0N_aZtBJRm26W4Q"
12
+ # }
13
+ # ]
14
+ # ```
12
15
  class Member < Base
13
16
  def initialize(member)
14
17
  @member_hash = case member