rusty_dropbox_sdk 0.1.0

Unofficial SDK for dropbox in Rust
Documentation
1
2
3
4
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
pub mod headers;
use super::tests_utils::{
    MOCK_SERVER_ASYNC_PORT, MOCK_SERVER_ASYNC_URL, MOCK_SERVER_SYNC_PORT, MOCK_SERVER_SYNC_URL,
};

/// Enum representing api available endpoints
/// It is passed to fhe function
#[derive(Debug)]
#[allow(dead_code)]
pub enum Endpoint {
    CheckAppPost,
    CheckUserPost,
    FileRequestsCountPost,
    FileRequestsCreatePost,
    FileRequestsDeleteAllClosedPost,
    ContactsDeleteManualContactsBatchPost,
    ContactsDeleteManualContactsPost,
    FileRequestsDeletePost,
    FilesCopyPost,
    FilesCopyBatchPost,
    FilesCopyBatchCheckPost,
    FilesCopyReferenceGetPost,
    FilesCopyReferenceSavePost,
    FilesCreateFolderPost,
    FilesCreateFolderBatchPost,
    FilesCreateFolderBatchCheckPost,
    FilesDeletePost,
    FilesDeleteBatchPost,
    FilesDeleteBatchCheckPost,
    FilesDownloadPost,
    FilesDownloadZipPost,
    FilesExportPost,
    FilesGetFileLockBatchPost,
    FilesGetMetadataPost,
    FilesGetPreviewPost,
    FilesGetTemporaryLinkPost,
    FilesGetTemporaryUploadLinkPost,
    FilesGetThumbnailPost,
    FilesGetThumbnailBatchPost,
    FilesListFolderPost,
    FilesListFolderContinuePost,
    FilesListFolderGetLatestCursorPost,
    FilesListFolderLongpollPost,
    FilesListRevisionsPost,
    FilesLockFileBatchPost,
    FilesMovePost,
    FilesMoveBatchPost,
    FilesMoveBatchCheckPost,
    FilesPaperCreatePost,
    FilesPaperUpdatePost,
    FilesPermanentlyDeletePost,
    FilesRestorePost,
    FilesSaveUrlPost,
    FilesSaveUrlCheckJobStatusPost,
    FilesSearchPost,
    FilesSearchContinuePost,
    FilesTagsAddPost,
    FilesTagsGetPost,
    FilesTagsRemovePost,
    FilesUnlockFileBatchPost,
    FilesUploadPost,
    FilesUploadSessionAppendPost,
    FilesUploadSessionAppendBatchPost,
    FilesUploadSessionFinishPost,
    FilesUploadSessionFinishBatchPost,
    FilesUploadSessionFinishBatchCheckPost,
    FilesUploadSessionStartPost,
    FilesUploadSessionStartBatchPost,
    FileRequestsGetPost,
    FileRequestsListContinuePost,
    FileRequestsListPost,
    FilePropertiesPropertiesAddPost,
    FilePropertiesPropertiesOverwritePost,
    FilePropertiesPropertiesRemovePost,
    FilePropertiesPropertiesSearchContinuePost,
    FilePropertiesPropertiesSearchPost,
    FilePropertiesPropertiesUpdatePost,
    AccountSetProfilePhotoPost,
    OpenidUserInfoPost,
    FilePropertiesTemplatesAddForUserPost,
    FilePropertiesTemplatesGetForUserPost,
    FilePropertiesTemplatesListForUserPost,
    FilePropertiesTemplatesRemoveForUserPost,
    FilePropertiesTemplatesUpdateForUserPost,
    AuthTokenRevokePost,
    FileRequestsUpdatePost,
    SharingAddFileMemberPost,
    SharingAddFolderMemberPost,
    SharingCheckJobStatusPost,
    SharingCheckRemoveMemberJobStatusPost,
    SharingCheckShareJobStatusPost,
    SharingCreateSharedLinkWithSettingsPost,
    SharingGetFileMetadataPost,
    SharingGetFileMetadataBatchPost,
    SharingGetFolderMetadataPost,
    SharingGetSharedLinkFilePost,
    SharingGetSharedLinkMetadataPost,
    SharingListFileMembersPost,
    SharingListFileMembersBatchPost,
    SharingListFileMembersContinuePost,
    SharingListFolderMembersPost,
    SharingListFolderMembersContinuePost,
    SharingListFoldersPost,
    SharingListFoldersContinuePost,
    SharingListMountableFoldersPost,
    SharingListMountableFoldersContinuePost,
    SharingListReceivedFilesPost,
    SharingListReceivedFilesContinuePost,
    SharingListSharedLinksPost,
    SharingModifySharedLinksSettingsPost,
    SharingMountFolderPost,
    SharingRelinquishFileMembershipPost,
    SharingRelinquishFolderMembershipPost,
    SharingRemoveFileMember2Post,
    SharingRemoveFolderMemberPost,
    SharingRevokeSharedLinkPost,
    SharingSetAccessInheritancePost,
    SharingShareFolderPost,
    SharingTransferFolderPost,
    SharingUnmountFolderPost,
    SharingUnshareFilePost,
    SharingUnshareFolderPost,
    SharingUpdateFileMemberPost,
    SharingUpdateFolderMemberPost,
    SharingUpdateFolderPolicyPost,
    UsersFeaturesGetValuesPost,
    UsersGetAccountPost,
    UsersGetAccountBatchPost,
    UsersGetCurrentAccountPost,
    UsersGetSpaceUsagePost,
}

#[allow(unused_variables)]
pub fn get_endpoint_url(endpoint: Endpoint) -> (String, Option<String>, Option<String>) {
    let url = match endpoint {
        Endpoint::CheckAppPost => "https://api.dropboxapi.com/2/check/app",
        Endpoint::FileRequestsCountPost => "https://api.dropboxapi.com/2/file_requests/count",
        Endpoint::FileRequestsCreatePost => "https://api.dropboxapi.com/2/file_requests/create",
        Endpoint::FileRequestsGetPost => "https://api.dropboxapi.com/2/file_requests/get",
        Endpoint::FileRequestsDeleteAllClosedPost => {
            "https://api.dropboxapi.com/2/delete_all_closed"
        }
        Endpoint::ContactsDeleteManualContactsBatchPost => {
            "https://api.dropboxapi.com/2/contacts/delete_manual_contacts_batch"
        }
        Endpoint::ContactsDeleteManualContactsPost => {
            "https://api.dropboxapi.com/2/contacts/delete_manual_contacts"
        }
        Endpoint::FilesDeletePost => "https://api.dropboxapi.com/2/delete",
        Endpoint::FilesUploadPost => "https://content.dropboxapi.com/2/files/upload",

        Endpoint::FilesTagsGetPost => "https://api.dropboxapi.com/2/get",
        Endpoint::FileRequestsListContinuePost => "https://api.dropboxapi.com/2/list/continue",
        Endpoint::FileRequestsListPost => "https://api.dropboxapi.com/2/list",
        Endpoint::FilePropertiesPropertiesAddPost => {
            "https://api.dropboxapi.com/2/file_properties/properties/add"
        }
        Endpoint::FilePropertiesPropertiesOverwritePost => {
            "https://api.dropboxapi.com/2/file_properties/properties/overwrite"
        }
        Endpoint::FilePropertiesPropertiesRemovePost => {
            "https://api.dropboxapi.com/2/file_properties/properties/remove"
        }
        Endpoint::FilePropertiesPropertiesSearchContinuePost => {
            "https://api.dropboxapi.com/2/file_properties/properties/search/continue"
        }
        Endpoint::FilePropertiesPropertiesSearchPost => {
            "https://api.dropboxapi.com/2/file_properties/properties/search"
        }
        Endpoint::FilePropertiesPropertiesUpdatePost => {
            "https://api.dropboxapi.com/2/file_properties/properties/update"
        }
        Endpoint::AccountSetProfilePhotoPost => {
            "https://api.dropboxapi.com/2/account/set_profile_photo"
        }
        Endpoint::FilePropertiesTemplatesAddForUserPost => {
            "https://api.dropboxapi.com/2/file_properties/templates/add_for_user"
        }
        Endpoint::FilePropertiesTemplatesGetForUserPost => {
            "https://api.dropboxapi.com/2/file_properties/templates/get_for_user"
        }
        Endpoint::FilePropertiesTemplatesListForUserPost => {
            "https://api.dropboxapi.com/2/file_properties/templates/list_for_user"
        }
        Endpoint::FilePropertiesTemplatesRemoveForUserPost => {
            "https://api.dropboxapi.com/2/file_properties/templates/remove_for_user"
        }
        Endpoint::FilePropertiesTemplatesUpdateForUserPost => {
            "https://api.dropboxapi.com/2/file_properties/templates/update_for_user"
        }
        Endpoint::AuthTokenRevokePost => "https://api.dropboxapi.com/2/auth/token/revoke",
        Endpoint::FileRequestsUpdatePost => "https://api.dropboxapi.com/2/update",
        Endpoint::CheckUserPost => "https://api.dropboxapi.com/2/check/user",
        Endpoint::UsersFeaturesGetValuesPost => {
            "https://api.dropboxapi.com/2/users/features/get_values"
        }
        Endpoint::UsersGetAccountBatchPost => {
            "https://api.dropboxapi.com/2/users/get_account_batch"
        }
        Endpoint::UsersGetAccountPost => "https://api.dropboxapi.com/2/users/get_account",
        Endpoint::UsersGetCurrentAccountPost => {
            "https://api.dropboxapi.com/2/users/get_current_account"
        }
        Endpoint::UsersGetSpaceUsagePost => "https://api.dropboxapi.com/2/users/get_space_usage",
        Endpoint::FileRequestsDeletePost => "https://api.dropboxapi.com/2/file_requests/delete",
        Endpoint::FilesCopyPost => "https://api.dropboxapi.com/2/files/copy_v2",
        Endpoint::FilesCopyBatchPost => "https://api.dropboxapi.com/2/files/copy_batch_v2",
        Endpoint::FilesCopyBatchCheckPost => {
            "https://api.dropboxapi.com/2/files/copy_batch/check_v2"
        }
        Endpoint::FilesCopyReferenceGetPost => {
            "https://api.dropboxapi.com/2/files/copy_reference/get"
        }
        Endpoint::FilesCopyReferenceSavePost => {
            "https://api.dropboxapi.com/2/files/copy_reference/save"
        }
        Endpoint::FilesCreateFolderPost => "https://api.dropboxapi.com/2/files/create_folder_v2",
        Endpoint::FilesCreateFolderBatchPost => {
            "https://api.dropboxapi.com/2/files/create_folder_batch"
        }
        Endpoint::FilesCreateFolderBatchCheckPost => {
            "https://api.dropboxapi.com/2/files/create_folder_batch/check"
        }
        Endpoint::FilesDeleteBatchPost => "https://api.dropboxapi.com/2/files/delete_batch",
        Endpoint::FilesDeleteBatchCheckPost => {
            "https://api.dropboxapi.com/2/files/delete_batch/check"
        }
        Endpoint::FilesDownloadPost => "https://content.dropboxapi.com/2/files/download",
        Endpoint::FilesDownloadZipPost => "https://content.dropboxapi.com/2/files/download_zip",
        Endpoint::FilesExportPost => "https://content.dropboxapi.com/2/files/export",
        Endpoint::FilesGetFileLockBatchPost => {
            "https://api.dropboxapi.com/2/files/get_file_lock_batch"
        }
        Endpoint::FilesGetMetadataPost => "https://api.dropboxapi.com/2/files/get_metadata",
        Endpoint::FilesGetPreviewPost => "https://content.dropboxapi.com/2/files/get_preview",
        Endpoint::FilesGetTemporaryLinkPost => {
            "https://api.dropboxapi.com/2/files/get_temporary_link"
        }
        Endpoint::FilesGetTemporaryUploadLinkPost => {
            "https://api.dropboxapi.com/2/files/get_temporary_upload_link"
        }
        Endpoint::FilesGetThumbnailPost => {
            "https://content.dropboxapi.com/2/files/get_thumbnail_v2"
        }
        Endpoint::FilesGetThumbnailBatchPost => {
            "https://content.dropboxapi.com/2/files/get_thumbnail_batch"
        }
        Endpoint::FilesListFolderPost => "https://api.dropboxapi.com/2/files/list_folder",
        Endpoint::FilesListFolderContinuePost => {
            "https://api.dropboxapi.com/2/files/list_folder/continue"
        }
        Endpoint::FilesListFolderGetLatestCursorPost => {
            "https://api.dropboxapi.com/2/files/list_folder/get_latest_cursor"
        }
        Endpoint::FilesListFolderLongpollPost => {
            "https://notify.dropboxapi.com/2/files/list_folder/longpoll"
        }
        Endpoint::FilesListRevisionsPost => "https://api.dropboxapi.com/2/files/list_revisions",
        Endpoint::FilesLockFileBatchPost => "https://api.dropboxapi.com/2/files/lock_file_batch",
        Endpoint::FilesMovePost => "https://api.dropboxapi.com/2/files/move_v2",
        Endpoint::FilesMoveBatchPost => "https://api.dropboxapi.com/2/files/move_batch_v2",
        Endpoint::FilesMoveBatchCheckPost => {
            "https://api.dropboxapi.com/2/files/move_batch/check_v2"
        }
        Endpoint::FilesPaperCreatePost => "https://api.dropboxapi.com/2/files/paper/create",
        Endpoint::FilesPaperUpdatePost => "https://api.dropboxapi.com/2/files/paper/update",
        Endpoint::FilesPermanentlyDeletePost => {
            "https://api.dropboxapi.com/2/files/permanently_delete"
        }
        Endpoint::FilesRestorePost => "https://api.dropboxapi.com/2/files/restore",
        Endpoint::FilesSaveUrlPost => "https://api.dropboxapi.com/2/files/save_url",
        Endpoint::FilesSaveUrlCheckJobStatusPost => {
            "https://api.dropboxapi.com/2/files/save_url/check_job_status"
        }
        Endpoint::FilesSearchPost => "https://api.dropboxapi.com/2/files/search_v2",
        Endpoint::FilesSearchContinuePost => {
            "https://api.dropboxapi.com/2/files/search/continue_v2"
        }
        Endpoint::FilesTagsAddPost => "https://api.dropboxapi.com/2/files/tags/add",
        Endpoint::FilesTagsRemovePost => "https://api.dropboxapi.com/2/files/tags/remove",
        Endpoint::FilesUnlockFileBatchPost => {
            "https://api.dropboxapi.com/2/files/unlock_file_batch"
        }
        Endpoint::FilesUploadSessionAppendPost => {
            "https://content.dropboxapi.com/2/files/upload_session/append_v2"
        }
        Endpoint::FilesUploadSessionAppendBatchPost => {
            "https://content.dropboxapi.com/2/files/upload_session/append_batch"
        }
        Endpoint::FilesUploadSessionFinishPost => {
            "https://content.dropboxapi.com/2/files/upload_session/finish"
        }
        Endpoint::FilesUploadSessionFinishBatchPost => {
            "https://api.dropboxapi.com/2/files/upload_session/finish_batch_v2"
        }
        Endpoint::FilesUploadSessionFinishBatchCheckPost => {
            "https://api.dropboxapi.com/2/files/upload_session/finish_batch/check"
        }
        Endpoint::FilesUploadSessionStartPost => {
            "https://content.dropboxapi.com/2/files/upload_session/start"
        }
        Endpoint::FilesUploadSessionStartBatchPost => {
            "https://api.dropboxapi.com/2/files/upload_session/start_batch"
        }
        Endpoint::OpenidUserInfoPost => "https://api.dropboxapi.com/2/openid/userinfo",
        Endpoint::SharingAddFileMemberPost => {
            "https://api.dropboxapi.com/2/sharing/add_file_member"
        }
        Endpoint::SharingAddFolderMemberPost => {
            "https://api.dropboxapi.com/2/sharing/add_folder_member"
        }
        Endpoint::SharingCheckJobStatusPost => {
            "https://api.dropboxapi.com/2/sharing/check_job_status"
        }
        Endpoint::SharingCheckRemoveMemberJobStatusPost => {
            "https://api.dropboxapi.com/2/sharing/check_remove_member_job_status"
        }
        Endpoint::SharingCheckShareJobStatusPost => {
            "https://api.dropboxapi.com/2/sharing/check_share_job_status"
        }
        Endpoint::SharingCreateSharedLinkWithSettingsPost => {
            "https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings"
        }
        Endpoint::SharingGetFileMetadataPost => {
            "https://api.dropboxapi.com/2/sharing/get_file_metadata"
        }
        Endpoint::SharingGetFileMetadataBatchPost => {
            "https://api.dropboxapi.com/2/sharing/get_file_metadata/batch"
        }
        Endpoint::SharingGetFolderMetadataPost => {
            "https://api.dropboxapi.com/2/sharing/get_folder_metadata"
        }
        Endpoint::SharingGetSharedLinkFilePost => {
            "https://content.dropboxapi.com/2/sharing/get_shared_link_file"
        }
        Endpoint::SharingGetSharedLinkMetadataPost => {
            "https://api.dropboxapi.com/2/sharing/get_shared_link_metadata"
        }
        Endpoint::SharingListFileMembersPost => {
            "https://api.dropboxapi.com/2/sharing/list_file_members"
        }
        Endpoint::SharingListFileMembersBatchPost => {
            "https://api.dropboxapi.com/2/sharing/list_file_members/batch"
        }
        Endpoint::SharingListFileMembersContinuePost => {
            "https://api.dropboxapi.com/2/sharing/list_file_members/continue"
        }
        Endpoint::SharingListFolderMembersPost => {
            "https://api.dropboxapi.com/2/sharing/list_folder_members"
        }
        Endpoint::SharingListFolderMembersContinuePost => {
            "https://api.dropboxapi.com/2/sharing/list_folder_members/continue"
        }
        Endpoint::SharingListFoldersPost => "https://api.dropboxapi.com/2/sharing/list_folders",
        Endpoint::SharingListFoldersContinuePost => {
            "https://api.dropboxapi.com/2/sharing/list_folders/continue"
        }
        Endpoint::SharingListMountableFoldersPost => {
            "https://api.dropboxapi.com/2/sharing/list_mountable_folders"
        }
        Endpoint::SharingListMountableFoldersContinuePost => {
            "https://api.dropboxapi.com/2/sharing/list_mountable_folders/continue"
        }
        Endpoint::SharingListReceivedFilesPost => {
            "https://api.dropboxapi.com/2/sharing/list_received_files"
        }
        Endpoint::SharingListReceivedFilesContinuePost => {
            "https://api.dropboxapi.com/2/sharing/list_received_files/continue"
        }
        Endpoint::SharingListSharedLinksPost => {
            "https://api.dropboxapi.com/2/sharing/list_shared_links"
        }
        Endpoint::SharingModifySharedLinksSettingsPost => {
            "https://api.dropboxapi.com/2/sharing/modify_shared_link_settings"
        }
        Endpoint::SharingMountFolderPost => "https://api.dropboxapi.com/2/sharing/mount_folder",
        Endpoint::SharingRelinquishFileMembershipPost => {
            "https://api.dropboxapi.com/2/sharing/relinquish_folder_membership"
        }
        Endpoint::SharingRelinquishFolderMembershipPost => {
            "https://api.dropboxapi.com/2/sharing/relinquish_folder_membership"
        }
        Endpoint::SharingRemoveFileMember2Post => {
            "https://api.dropboxapi.com/2/sharing/remove_file_member_2"
        }
        Endpoint::SharingRemoveFolderMemberPost => {
            "https://api.dropboxapi.com/2/sharing/remove_folder_member"
        }
        Endpoint::SharingRevokeSharedLinkPost => {
            "https://api.dropboxapi.com/2/sharing/revoke_shared_link"
        }
        Endpoint::SharingSetAccessInheritancePost => {
            "https://api.dropboxapi.com/2/sharing/set_access_inheritance"
        }
        Endpoint::SharingShareFolderPost => "https://api.dropboxapi.com/2/sharing/share_folder",
        Endpoint::SharingTransferFolderPost => {
            "https://api.dropboxapi.com/2/sharing/transfer_folder"
        }
        Endpoint::SharingUnmountFolderPost => "https://api.dropboxapi.com/2/sharing/unmount_folder",
        Endpoint::SharingUnshareFilePost => "https://api.dropboxapi.com/2/sharing/unshare_file",
        Endpoint::SharingUnshareFolderPost => "https://api.dropboxapi.com/2/sharing/unshare_folder",
        Endpoint::SharingUpdateFileMemberPost => {
            "https://api.dropboxapi.com/2/sharing/update_file_member"
        }
        Endpoint::SharingUpdateFolderMemberPost => {
            "https://api.dropboxapi.com/2/sharing/update_folder_member"
        }
        Endpoint::SharingUpdateFolderPolicyPost => {
            "https://api.dropboxapi.com/2/sharing/update_folder_policy"
        }
    };

    let binding: (String, Option<String>, Option<String>) = (url.to_string(), None, None);
    #[cfg(feature = "test-utils")]
    let binding = test_url(url);

    binding
}

/// For testing purpose, it will replace original end-point with mock server url
#[allow(unused)]
fn test_url(url: &str) -> (String, Option<String>, Option<String>) {
    let idx = url.find("com").expect("should have com") + 3;

    let url_test_sync = format!(
        "http://{}:{}{}",
        MOCK_SERVER_SYNC_URL,
        MOCK_SERVER_SYNC_PORT,
        &url[idx..]
    );
    let url_test_async = format!(
        "http://{}:{}{}",
        MOCK_SERVER_ASYNC_URL,
        MOCK_SERVER_ASYNC_PORT,
        &url[idx..]
    );
    (url.to_string(), Some(url_test_sync), Some(url_test_async))
}