diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2016-02-22 21:12:25 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2016-02-22 21:12:25 +0000 |
commit | 0b82b879821c7e73b86f189be747c5634c8b46b7 (patch) | |
tree | 28c7e3b06c25a7b9fbd49a33972e7fae07dd2e56 /plugins/Dropbox/src/api/operations.h | |
parent | 477664ed5c4b018562e9419428175ae938cf2761 (diff) |
Dropbox:
- updated api to v2
- version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@16326 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dropbox/src/api/operations.h')
-rw-r--r-- | plugins/Dropbox/src/api/operations.h | 74 |
1 files changed, 54 insertions, 20 deletions
diff --git a/plugins/Dropbox/src/api/operations.h b/plugins/Dropbox/src/api/operations.h index e41dbaabfe..71c455d1e8 100644 --- a/plugins/Dropbox/src/api/operations.h +++ b/plugins/Dropbox/src/api/operations.h @@ -4,54 +4,88 @@ class ShareRequest : public HttpRequest
{
public:
- ShareRequest(const char *token, const char *path, bool useShortUrl, const char *root = "auto") :
- HttpRequest(REQUEST_POST, FORMAT, DROPBOX_API_URL "/shares/%s/%s", root, path)
+ ShareRequest(const char *token, const char *path, time_t expires = 0) :
+ HttpRequest(REQUEST_POST, DROPBOX_API_RPC "/sharing/create_shared_link_with_settings")
{
- if (!useShortUrl)
- AddUrlParameter("short_url=false");
-
AddBearerAuthHeader(token);
- AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ AddHeader("Content-Type", "application/json");
+
+ JSONNode root(JSON_NODE);
+ root << JSONNode("path", path);
+
+ if (expires)
+ root << JSONNode("expires", (unsigned int)expires);
+
+ json_string data = root.write();
+ SetData(data.c_str(), data.length());
}
};
class DeleteRequest : public HttpRequest
{
public:
- DeleteRequest(const char *token, const char *path, const char *root = "auto") :
- HttpRequest(REQUEST_POST, DROPBOX_API_URL "/fileops/delete")
+ DeleteRequest(const char *token, const char *path) :
+ HttpRequest(REQUEST_POST, DROPBOX_API_RPC "/files/delete")
{
AddBearerAuthHeader(token);
- AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ AddHeader("Content-Type", "application/json");
+
+ JSONNode root(JSON_NODE);
+ root << JSONNode("path", path);
- CMStringA data(CMStringDataFormat::FORMAT, "root=%s&path=%s", root, path);
- data.Replace('\\', '/');
- SetData(data.GetBuffer(), data.GetLength());
+ json_string data = root.write();
+ SetData(data.c_str(), data.length());
}
};
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")
+ CreateFolderRequest(const char *token, const char *path) :
+ HttpRequest(REQUEST_POST, DROPBOX_API_RPC "/files/create_folder")
{
AddBearerAuthHeader(token);
- AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ AddHeader("Content-Type", "application/json");
- CMStringA data(CMStringDataFormat::FORMAT, "root=%s&path=%s", root, path);
- data.Replace('\\', '/');
- SetData(data.GetBuffer(), data.GetLength());
+ 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, const char *root = "auto") :
- HttpRequest(REQUEST_GET, FORMAT, DROPBOX_API_URL "/metadata/%s/%s", root, path)
+ 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());
}
};
|