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
|
#ifndef _DROPBOX_API_OPERATIONS_H_
#define _DROPBOX_API_OPERATIONS_H_
class ShareRequest : public HttpRequest
{
public:
ShareRequest(const char *token, const char *path, bool useShortUrl = true, const char *root = "auto") :
HttpRequest(REQUEST_POST, FORMAT, DROPBOX_API_URL "/shares/%s/%s", root, path)
{
if (!useShortUrl)
AddUrlParameter("short_url=false");
AddBearerAuthHeader(token);
AddHeader("Content-Type", "application/x-www-form-urlencoded");
}
};
class DeleteRequest : public HttpRequest
{
public:
DeleteRequest(const char *token, const char *path, const char *root = "auto") :
HttpRequest(REQUEST_POST, DROPBOX_API_URL "/fileops/delete")
{
AddBearerAuthHeader(token);
AddHeader("Content-Type", "application/x-www-form-urlencoded");
CMStringA data(CMStringDataFormat::FORMAT, "root=%s&path=%s", root, path);
data.Replace('\\', '/');
SetData(data.GetBuffer(), data.GetLength());
}
};
class CreateFolderRequest : public HttpRequest
{
public:
CreateFolderRequest(const char *token, const char *path, const char *root = "auto") :
HttpRequest(REQUEST_POST, DROPBOX_API_URL "/fileops/create_folder")
{
AddBearerAuthHeader(token);
AddHeader("Content-Type", "application/x-www-form-urlencoded");
CMStringA data(CMStringDataFormat::FORMAT, "root=%s&path=%s", root, path);
data.Replace('\\', '/');
SetData(data.GetBuffer(), data.GetLength());
}
};
class GetMetadataRequest : public HttpRequest
{
public:
GetMetadataRequest(const char *token, const char *path, const char *root = "auto") :
HttpRequest(REQUEST_GET, FORMAT, DROPBOX_API_URL "/metadata/%s/%s", root, path)
{
AddBearerAuthHeader(token);
}
};
#endif //_DROPBOX_API_OPERATIONS_H_
|