Appwrite C++ SDK
Auto-generated API documentation for the Appwrite C++ SDK
Loading...
Searching...
No Matches
Utils.hpp
Go to the documentation of this file.
1/// @file Utils.hpp
2/// @brief Provides utility functions and helpers used across the SDK.
3
4#ifndef UTILS_HPP
5#define UTILS_HPP
6
7#include <string>
8#include <vector>
9
10/**
11 * @class Utils
12 * @brief Provides static utility functions for HTTP requests and data
13 * formatting.
14 */
15class Utils {
16 public:
17 /**
18 * @brief Make an HTTP POST request.
19 *
20 * @param url Endpoint URL.
21 * @param payload JSON payload to send.
22 * @param headers List of HTTP headers.
23 * @param response Output string to store server response.
24 * @return int HTTP response code.
25 */
26 static int postRequest(const std::string &url, const std::string &payload,
27 const std::vector<std::string> &headers,
28 std::string &response);
29
30 /**
31 * @brief Make an HTTP PUT request.
32 *
33 * @param url Endpoint URL.
34 * @param payload JSON payload to send.
35 * @param headers List of HTTP headers.
36 * @param response Output string to store server response.
37 * @return int HTTP response code.
38 */
39 static int putRequest(const std::string &url, const std::string &payload,
40 const std::vector<std::string> &headers,
41 std::string &response);
42
43 /**
44 * @brief Make an HTTP PATCH request.
45 *
46 * @param url Endpoint URL.
47 * @param payload JSON payload to send.
48 * @param headers List of HTTP headers.
49 * @param response Output string to store server response.
50 * @return int HTTP response code.
51 */
52 static int patchRequest(const std::string &url, const std::string &payload,
53 const std::vector<std::string> &headers,
54 std::string &response);
55
56 /**
57 * @brief Make an HTTP GET request.
58 *
59 * @param url Endpoint URL.
60 * @param headers List of HTTP headers.
61 * @param response Output string to store server response.
62 * @return int HTTP response code.
63 */
64 static int getRequest(const std::string &url,
65 const std::vector<std::string> &headers,
66 std::string &response);
67
68 /**
69 * @brief Make an HTTP DELETE request.
70 *
71 * @param url Endpoint URL.
72 * @param headers List of HTTP headers.
73 * @param response Output string to store server response.
74 * @return int HTTP response code.
75 */
76 static int deleteRequest(const std::string &url,
77 const std::vector<std::string> &headers,
78 std::string &response);
79
80 /**
81 * @brief URL-encode a string.
82 *
83 * @param value Input string.
84 * @return std::string URL-encoded string.
85 */
86 static std::string urlEncode(const std::string &value);
87
88 /**
89 * @brief Escape special characters in a JSON string.
90 *
91 * @param input Input string.
92 * @return std::string Escaped JSON string.
93 */
94 static std::string escapeJsonString(const std::string &input);
95
96 /**
97 * @brief Convert a boolean to a string ("true"/"false").
98 *
99 * @param value Boolean value.
100 * @return std::string "true" or "false".
101 */
102 static std::string boolToString(bool value);
103};
104
105#endif
Provides static utility functions for HTTP requests and data formatting.
Definition Utils.hpp:15
static std::string escapeJsonString(const std::string &input)
Escape special characters in a JSON string.
static int deleteRequest(const std::string &url, const std::vector< std::string > &headers, std::string &response)
Make an HTTP DELETE request.
static std::string boolToString(bool value)
Convert a boolean to a string ("true"/"false").
static int patchRequest(const std::string &url, const std::string &payload, const std::vector< std::string > &headers, std::string &response)
Make an HTTP PATCH request.
static std::string urlEncode(const std::string &value)
URL-encode a string.
static int putRequest(const std::string &url, const std::string &payload, const std::vector< std::string > &headers, std::string &response)
Make an HTTP PUT request.
static int postRequest(const std::string &url, const std::string &payload, const std::vector< std::string > &headers, std::string &response)
Make an HTTP POST request.
static int getRequest(const std::string &url, const std::vector< std::string > &headers, std::string &response)
Make an HTTP GET request.