-
Notifications
You must be signed in to change notification settings - Fork 10
/
Rest.h
81 lines (72 loc) · 1.88 KB
/
Rest.h
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
/*
* Twilio REST C++
* Author: Laurent Luce
*/
#ifndef TWILIOREST_H
#define TWILIOREST_H
namespace twilio {
class Rest {
public:
/**
* Constructor
* @param id Twilio account SID
* @param token Twilio account token
*/
Rest(const string& id, const string& token)
{
tid = id;
ttoken = token;
}
/**
* HTTP request
* @param path URL path
* @param method HTTP method: "GET", "POST", "PUT", "DELETE"
* @param vars URL attributes or POST attributes
* @return HTTP response
*/
string request(const string& path, const string& method, const vector<Var>& vars);
private:
/** Twilio account SID */
string tid;
/** Twilio account token */
string ttoken;
/** Response buffer */
string tbuffer;
/** Twilio API URL - set in cpp */
static const string TWILIO_API_URL;
/**
* Prefix path with Twilio URL
* @param path URL path
* @return full URL
*/
string build_uri(const string& path) const;
/**
* HTTP GET request
* @param url HTTP request URL
* @param vars URL attributes
* @return HTTP response
*/
string get(const string& url, const vector<Var>& vars);
/**
* HTTP POST request
* @param url HTTP request URL
* @param vars POST attributes
* @return HTTP response
*/
string post(const string& url, const vector<Var>& vars);
/**
* HTTP PUT request
* @param url HTTP request URL
* @param filename File to read data from
* @return HTTP response
*/
string put(const string& url, const string& filename);
/**
* HTTP DELETE request
* @param url HTTP request URL
* @return HTTP response
*/
string tdelete(const string& url);
};
}
#endif