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
|
#ifndef _DROPBOX_API_OPERATIONS_H_
#define _DROPBOX_API_OPERATIONS_H_
class GetTemporaryLinkRequest : public HttpRequest
{
public:
GetTemporaryLinkRequest(const char *token, const char *path) :
HttpRequest(REQUEST_POST, DROPBOX_API_RPC "/files/get_temporary_link")
{
AddBearerAuthHeader(token);
AddHeader("Content-Type", "application/json");
JSONNode root(JSON_NODE);
root << JSONNode("path", path);
json_string data = root.write();
SetData(data.c_str(), data.length());
}
};
class CreateSharedLinkRequest : public HttpRequest
{
public:
CreateSharedLinkRequest(const char *token, const char *path) :
HttpRequest(REQUEST_POST, DROPBOX_API_RPC "/sharing/create_shared_link_with_settings")
{
AddBearerAuthHeader(token);
AddHeader("Content-Type", "application/json");
JSONNode root(JSON_NODE);
root << JSONNode("path", path);
json_string data = root.write();
SetData(data.c_str(), data.length());
}
};
class GetSharedLinkRequest : public HttpRequest
{
public:
GetSharedLinkRequest(const char *token, const char *path) :
HttpRequest(REQUEST_POST, DROPBOX_API_RPC "/sharing/list_shared_links")
{
AddBearerAuthHeader(token);
AddHeader("Content-Type", "application/json");
JSONNode root(JSON_NODE);
root << JSONNode("path", path);
json_string data = root.write();
SetData(data.c_str(), data.length());
}
};
class SearchRequest : public HttpRequest
{
public:
SearchRequest(const char *token, const char *query) :
HttpRequest(REQUEST_POST, DROPBOX_API_RPC "/files/search")
{
AddBearerAuthHeader(token);
AddHeader("Content-Type", "application/json");
JSONNode params(JSON_NODE);
params
<< JSONNode("path", "")
<< JSONNode("query", query)
<< JSONNode("max_results", 10);
json_string data = params.write();
SetData(data.c_str(), data.length());
}
};
class DeleteRequest : public HttpRequest
{
public:
DeleteRequest(const char *token, const char *path) :
HttpRequest(REQUEST_POST, DROPBOX_API_RPC "/files/delete")
{
AddBearerAuthHeader(token);
AddHeader("Content-Type", "application/json");
JSONNode root(JSON_NODE);
root << JSONNode("path", path);
json_string data = root.write();
SetData(data.c_str(), data.length());
}
};
class CreateFolderRequest : public HttpRequest
{
public:
CreateFolderRequest(const char *token, const char *path) :
HttpRequest(REQUEST_POST, DROPBOX_API_RPC "/files/create_folder")
{
AddBearerAuthHeader(token);
AddHeader("Content-Type", "application/json");
JSONNode root(JSON_NODE);
root << JSONNode("path", path);
json_string data = root.write();
SetData(data.c_str(), data.length());
}
};
class GetMetadataRequest : public HttpRequest
{
public:
GetMetadataRequest(const char *token, const char *path) :
HttpRequest(REQUEST_POST, DROPBOX_API_RPC "/files/get_metadata")
{
AddBearerAuthHeader(token);
AddHeader("Content-Type", "application/json");
JSONNode root(JSON_NODE);
root << JSONNode("path", path);
json_string data = root.write();
SetData(data.c_str(), data.length());
}
};
class ListFolderRequest : public HttpRequest
{
public:
ListFolderRequest(const char *token, const char *path) :
HttpRequest(REQUEST_POST, DROPBOX_API_RPC "/files/list_folder")
{
AddBearerAuthHeader(token);
AddHeader("Content-Type", "application/json");
JSONNode root(JSON_NODE);
root << JSONNode("path", path);
json_string data = root.write();
SetData(data.c_str(), data.length());
}
};
#endif //_DROPBOX_API_OPERATIONS_H_
|