Executes HTTP requests by using the base url and the provided parameters and body. This class will handle retries based on the RetrySettings and will merge all similar URL requests into one.
More...
#include <OlpClient.h>
|
using | ParametersType = std::multimap< std::string, std::string > |
| An alias for the parameters and headers type.
|
|
using | RequestBodyType = std::shared_ptr< std::vector< std::uint8_t > > |
| An alias for the HTTP request body.
|
|
|
| OlpClient (const OlpClientSettings &settings, std::string base_url) |
| Creates the OlpClient instance. More...
|
|
| OlpClient (const OlpClient &) |
| A copy constructor.
|
|
OlpClient & | operator= (const OlpClient &) |
| An assignement operator.
|
|
| OlpClient (OlpClient &&) noexcept |
| A move constructor.
|
|
OlpClient & | operator= (OlpClient &&) noexcept |
| A move assignement operator.
|
|
void | SetBaseUrl (const std::string &base_url) |
| Sets the base URL used for all requests. More...
|
|
std::string | GetBaseUrl () const |
| Gets the base URL. More...
|
|
ParametersType & | GetMutableDefaultHeaders () |
| Gets the default headers that are added to each request. More...
|
|
const OlpClientSettings & | GetSettings () const |
| Getter function to retrieve client settings. More...
|
|
CancellationToken | CallApi (const std::string &path, const std::string &method, const ParametersType &query_params, const ParametersType &header_params, const ParametersType &form_params, const RequestBodyType &post_body, const std::string &content_type, const NetworkAsyncCallback &callback) const |
| Executes the HTTP request through the network stack. More...
|
|
HttpResponse | CallApi (std::string path, std::string method, ParametersType query_params, ParametersType header_params, ParametersType form_params, RequestBodyType post_body, std::string content_type, CancellationContext context) const |
| Executes the HTTP request through the network stack in a blocking way. More...
|
|
HttpResponse | CallApiStream (std::string path, std::string method, ParametersType query_params, ParametersType header_params, http::Network::DataCallback data_callback, RequestBodyType post_body, std::string content_type, CancellationContext context) const |
| Executes the HTTP request through the network stack in a blocking way. The response content is consumed via data callback. More...
|
|
Executes HTTP requests by using the base url and the provided parameters and body. This class will handle retries based on the RetrySettings and will merge all similar URL requests into one.
◆ OlpClient()
olp::client::OlpClient::OlpClient |
( |
const OlpClientSettings & |
settings, |
|
|
std::string |
base_url |
|
) |
| |
Creates the OlpClient
instance.
- Parameters
-
settings | The OlpClientSettings instance. |
base_url | The base URL to be used for all outgoing requests. |
◆ CallApi() [1/2]
Executes the HTTP request through the network stack.
- Parameters
-
path | The path that is appended to the base URL. |
method | Select one of the following methods: GET , POST , DELETE , or PUT . |
query_params | The parameters that are appended to the URL path. |
header_params | The headers used to customize the request. |
form_params | For the POST request, populate form_params or post_body , but not both. |
post_body | For the POST request, populate form_params or post_body , but not both. This data must not be modified until the request is completed. |
content_type | The content type for the post_body or form_params . |
callback | The function callback used to receive the HttpResponse instance. |
- Returns
- The method used to call or to cancel the request.
◆ CallApi() [2/2]
Executes the HTTP request through the network stack in a blocking way.
- Parameters
-
path | The path that is appended to the base URL. |
method | Select one of the following methods: GET , POST , DELETE , or PUT . |
query_params | The parameters that are appended to the URL path. |
header_params | The headers used to customize the request. |
form_params | For the POST request, populate form_params or post_body , but not both. |
post_body | For the POST request, populate form_params or post_body , but not both. This data must not be modified until the request is completed. |
content_type | The content type for the post_body or form_params . |
context | The CancellationContext instance that is used to cancel the request. |
- Returns
- The
HttpResponse
instance.
◆ CallApiStream()
Executes the HTTP request through the network stack in a blocking way. The response content is consumed via data callback.
- Parameters
-
path | The path that is appended to the base URL. |
method | Select one of the following methods: GET , POST , DELETE , or PUT . |
query_params | The parameters that are appended to the URL path. |
header_params | The headers used to customize the request. |
data_callback | The network data callback to retrieve content. |
post_body | For the POST request, populate form_params or post_body , but not both. This data must not be modified until the request is completed. |
content_type | The content type for the post_body or form_params . |
context | The CancellationContext instance that is used to cancel the request. |
- Returns
- The
HttpResponse
instance.
◆ GetBaseUrl()
std::string olp::client::OlpClient::GetBaseUrl |
( |
| ) |
const |
Gets the base URL.
- Returns
- The base URL.
◆ GetMutableDefaultHeaders()
Gets the default headers that are added to each request.
- Note
- Do not change this while requests are ongoing.
- Returns
- The default headers.
◆ GetSettings()
Getter function to retrieve client settings.
- Returns
- The client settings
◆ SetBaseUrl()
void olp::client::OlpClient::SetBaseUrl |
( |
const std::string & |
base_url | ) |
|
Sets the base URL used for all requests.
- Note
- The base URL can change over time and it is thread safe to change it.
- Parameters
-
base_url | The new base URL to be used for all outgoing requests. |
The documentation for this class was generated from the following file: