summaryrefslogtreecommitdiff
path: root/plugins/Dropbox/src/api/operations.h
blob: 1ff7d5023014b1cdc95792a0b36a67922bbdf852 (plain)
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
#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) :
		HttpRequest(REQUEST_POST, FORMAT, DROPBOX_API_URL "/shares/auto/%s", 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) :
		HttpRequest(REQUEST_POST, DROPBOX_API_URL "/fileops/delete")
	{
		AddBearerAuthHeader(token);
		AddHeader("Content-Type", "application/x-www-form-urlencoded");

		CMStringA data(CMStringDataFormat::FORMAT, "root=auto&path=%s", path);
		data.Replace('\\', '/');
		pData = data.GetBuffer();
		dataLength = data.GetLength();
	}
};

class CreateFolderRequest : public HttpRequest
{
public:
	CreateFolderRequest(const char *token, const char *path) :
		HttpRequest(REQUEST_POST, DROPBOX_API_URL "/fileops/create_folder")
	{
		AddBearerAuthHeader(token);
		AddHeader("Content-Type", "application/x-www-form-urlencoded");

		CMStringA data(CMStringDataFormat::FORMAT, "root=auto&path=%s", path);
		data.Replace('\\', '/');
		pData = data.GetBuffer();
		dataLength = data.GetLength();
	}
};

class GetMetadataRequest : public HttpRequest
{
public:
	GetMetadataRequest(const char *token, const char *path) :
		HttpRequest(REQUEST_GET, FORMAT, DROPBOX_API_URL "/metadata/auto/%s", path)
	{
		AddBearerAuthHeader(token);
	}
};

#endif //_DROPBOX_API_OPERATIONS_H_