1#ifndef TENDUKE_SE_LICENSING_REST_ABSTRACTAPIREQUEST_H
2#define TENDUKE_SE_LICENSING_REST_ABSTRACTAPIREQUEST_H
4#include "./APIRequest.h"
5#include "../config/BackendConfiguration.h"
6#include "http/HTTPClient.h"
7#include "http/HTTPRequestAuthenticator.h"
8#include "http/HTTPResponseToException.h"
9#include "json/JSONParser.h"
15namespace tenduke {
namespace se {
namespace licensing {
namespace rest {
38 ,
const std::shared_ptr<const ::tenduke::http::HTTPClient> &httpClient
40 ,
const std::shared_ptr<const ::tenduke::http::HTTPResponseToException> &
throwException
41 ,
const std::shared_ptr<const ::tenduke::json::JSONParser> &jsonParser
70 if (! response->isSuccessful()) {
74 return fromJSON(response->getPayloadAsString());
111 const std::shared_ptr<const ::tenduke::http::HTTPClient>
http;
117 const std::shared_ptr<const ::tenduke::http::HTTPResponseToException>
throwException;
120 const std::shared_ptr<const ::tenduke::json::JSONParser>
parseJSON;
Builds HTTPRequest.
Definition HTTPRequestBuilder.h:22
std::unique_ptr< HTTPRequest > build()
Builds the request.
Definition HTTPRequestBuilder.cpp:21
HTTPRequestBuilder & authenticateWith(const std::shared_ptr< const tenduke::http::HTTPRequestAuthenticator > &requestAuthenticator)
Sets the request authenticator.
Definition HTTPRequestBuilder.cpp:97
HTTPRequestBuilder & url(const std::string &url)
Sets the request URL.
Definition HTTPRequestBuilder.cpp:91
Very simple URL-builder.
Definition URLBuilder.h:19
A tenduke::se::APIRequest, which uses tenduke::oidc::OIDCSession to maintain request authorization.
Definition StatefulAPIRequest.h:27
R execute() override
Execute the request synchronously.
Definition StatefulAPIRequest.h:42
Abstract base-class with generic implementation for 10Duke Scale API requests.
Definition AbstractAPIRequestMixin.h:26
const std::shared_ptr< const ::tenduke::http::HTTPResponseToException > throwException
Service to throw exceptions based on HTTP status codes.
Definition AbstractAPIRequestMixin.h:117
virtual T executeRequest()
Executes the request.
Definition AbstractAPIRequestMixin.h:56
const std::string baseUrl
Base-URL for the request.
Definition AbstractAPIRequestMixin.h:108
const std::shared_ptr< const ::tenduke::http::HTTPClient > http
HTTP-client to execute the request.
Definition AbstractAPIRequestMixin.h:111
virtual T fromJSON(const std::string &responseBody) const =0
Converts the response body from JSON to the response type.
const std::shared_ptr< const ::tenduke::http::HTTPRequestAuthenticator > httpRequestAuthenticator
For authenticating the request.
Definition AbstractAPIRequestMixin.h:114
const std::shared_ptr< const ::tenduke::json::JSONParser > parseJSON
For parsing the response payload.
Definition AbstractAPIRequestMixin.h:120
virtual ::tenduke::http::HTTPRequestBuilder & setHeaders(::tenduke::http::HTTPRequestBuilder &request) const
Sets additional headers.
Definition AbstractAPIRequestMixin.h:100
AbstractAPIRequestMixin(std::string baseUrl, const std::shared_ptr< const ::tenduke::http::HTTPClient > &httpClient, const std::shared_ptr< const ::tenduke::http::HTTPRequestAuthenticator > &httpRequestAuthenticator, const std::shared_ptr< const ::tenduke::http::HTTPResponseToException > &throwException, const std::shared_ptr< const ::tenduke::json::JSONParser > &jsonParser)
Constructs new instance.
Definition AbstractAPIRequestMixin.h:36
virtual void buildUrl(::tenduke::net::URLBuilder &urlBuilder) const
Builds the request URL.
Definition AbstractAPIRequestMixin.h:89
Root for classes, functions and globals of 10Duke C++ Client.
Definition BackendConfiguration.h:7