Botcraft 26.3
Loading...
Searching...
No Matches
Https.hpp
Go to the documentation of this file.
1#ifdef USE_ENCRYPTION
2#pragma once
3
5
6#include <string>
7#include <vector>
8
9namespace Botcraft
10{
17
18 /// @brief Send a POST request with ssl stuff
19 /// @param host The host address (after https:// and before the first /)
20 /// @param endpoint The endpoint (after the first /)
21 /// @param content_type Data type
22 /// @param accept Accept header value
23 /// @param data Actual data to send
24 /// @param authorization Optional authorization header, only if not empty
25 /// @return A WebRequestResponse returned by the server
27 const std::string& host, const std::string& endpoint,
28 const std::string& content_type, const std::string& accept,
29 const std::string& authorization, const std::string& data
30 );
31
32 /// @brief Send a GET request with ssl stuff
33 /// @param host The host address (after https:// and before the first /)
34 /// @param endpoint The endpoint (after the first /)
35 /// @param authorization Optional authorization header, only set if not empty
36 /// @return A WebRequestResponse returned by the server
38 const std::string& host,
39 const std::string& endpoint,
40 const std::string& authorization = ""
41 );
42
43 /// @brief Check that a WebRequestResponse has the right fields and return code, throw if not
44 /// @param response
45 /// @param s String to display in the error message
46 /// @param fields Expected fields to have in the response
47 /// @param expected_status
48 /// @return The response as json
50 const WebRequestResponse& response,
51 const std::string& s,
52 const std::vector<std::string>& fields,
53 const unsigned int expected_status = 200
54 );
55
56}
57#endif // USE_ENCRYPTION
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45
WebRequestResponse GETRequest(const std::string &host, const std::string &endpoint, const std::string &authorization="")
Send a GET request with ssl stuff.
Definition Https.cpp:305
ProtocolCraft::Json::Value CheckJsonResponse(const WebRequestResponse &response, const std::string &s, const std::vector< std::string > &fields, const unsigned int expected_status=200)
Check that a WebRequestResponse has the right fields and return code, throw if not.
Definition Https.cpp:326
WebRequestResponse POSTRequest(const std::string &host, const std::string &endpoint, const std::string &content_type, const std::string &accept, const std::string &authorization, const std::string &data)
Send a POST request with ssl stuff.
Definition Https.cpp:279
ProtocolCraft::Json::Value response
Definition Https.hpp:13