#include <ApiRequest.hpp>
|
| ApiRequest ()=delete |
|
| ApiRequest (const std::string &apiBaseURL, std::string_view apiRoute) |
|
bool | post (const JSON &body, const std::optional< HeaderFields > &headers=std::nullopt, const std::optional< std::reference_wrapper< JSON > > &responseBody=std::nullopt) |
| POST request to send a request to the API. This request is used to create a new resource.
|
|
bool | get (JSON &responseBody, const std::unordered_map< std::string_view, std::string > &queryParams={}) const |
| GET request with query params. This request is used to get a resource.
|
|
bool | put (const JSON &body, const HeaderFields *headers=nullptr) const |
| PUT request to send a request to the API. This request is used to update a resource.
|
|
bool | DELETE (JSON &responseBody, const std::unordered_map< std::string_view, std::string > &queryParams={}) const |
|
|
static std::string | urlEncode (const std::unordered_map< std::string_view, std::string > &queryParams) |
|
◆ ApiRequest() [1/2]
iv::comms::api::ApiRequest::ApiRequest |
( |
| ) |
|
|
delete |
◆ ApiRequest() [2/2]
iv::comms::api::ApiRequest::ApiRequest |
( |
const std::string & | apiBaseURL, |
|
|
std::string_view | apiRoute ) |
◆ DELETE()
bool iv::comms::api::ApiRequest::DELETE |
( |
JSON & | responseBody, |
|
|
const std::unordered_map< std::string_view, std::string > & | queryParams = {} ) const |
◆ get()
bool iv::comms::api::ApiRequest::get |
( |
JSON & | responseBody, |
|
|
const std::unordered_map< std::string_view, std::string > & | queryParams = {} ) const |
GET request with query params. This request is used to get a resource.
- Parameters
-
responseBody[out] | Gets the response body in JSON format. |
queryParams | Query params for GET request. |
- Returns
- TRUE if GET request is successful, otherwise, FALSE.
◆ post()
bool iv::comms::api::ApiRequest::post |
( |
const JSON & | body, |
|
|
const std::optional< HeaderFields > & | headers = std::nullopt, |
|
|
const std::optional< std::reference_wrapper< JSON > > & | responseBody = std::nullopt ) |
POST request to send a request to the API. This request is used to create a new resource.
- Parameters
-
body | JSON body to send. |
headers | Headers to send. |
responseBody | [out] Gets the response body in JSON format. |
- Returns
- TRUE if POST request is successful, otherwise, FALSE.
◆ put()
bool iv::comms::api::ApiRequest::put |
( |
const JSON & | body, |
|
|
const HeaderFields * | headers = nullptr ) const |
PUT request to send a request to the API. This request is used to update a resource.
- Parameters
-
body | JSON body to send. |
headers | Headers to send. |
- Returns
- TRUE if PUT request is successful, otherwise, FALSE.
◆ urlEncode()
std::string iv::comms::api::ApiRequest::urlEncode |
( |
const std::unordered_map< std::string_view, std::string > & | queryParams | ) |
|
|
static |
◆ m_apiBaseURL
std::string iv::comms::api::ApiRequest::m_apiBaseURL |
|
private |
◆ m_apiRoute
std::string iv::comms::api::ApiRequest::m_apiRoute |
|
private |
◆ m_headers
The documentation for this class was generated from the following files: