1#ifndef TENDUKE_EE_LICENSING_AUTZHAPI_ABSTRACTAUTHZAPIREQUEST_H
2#define TENDUKE_EE_LICENSING_AUTZHAPI_ABSTRACTAUTHZAPIREQUEST_H
4#include "../LicensingRequest.h"
5#include "http/HTTPClient.h"
6#include "http/HTTPRequestAuthenticator.h"
7#include "http/HTTPResponseToException.h"
35 const std::shared_ptr<const ::tenduke::http::HTTPClient> &httpClient,
36 const std::shared_ptr<const ::tenduke::http::HTTPRequestAuthenticator> &httpRequestAuthenticator,
37 const std::shared_ptr<const ::tenduke::http::HTTPResponseToException> &throwException,
38 const std::shared_ptr<::tenduke::log::Logger> &logger
40 , httpRequestAuthenticator(httpRequestAuthenticator)
41 , throwException(throwException)
53 auto request = http->request();
54 auto urlBuilder = request.url();
56 std::string url = urlBuilder.buildString();
58 if (this->log->isDebugEnabled()) {
59 this->log->debug(
"AbstractAuthzApiRequest::execute() Executing HTTP request with URL " + url +
" ...");
63 auto httpCall = request.get()
64 .authenticateWith(httpRequestAuthenticator)
67 auto httpResponse = httpCall->execute();
69 if (! httpResponse->isSuccessful()) {
70 this->log->warning(
"AbstractAuthzApiRequest::execute() ...HTTP request failed with status code " + std::to_string(httpResponse->getStatusCode()));
71 throwException->basedOn(*httpResponse);
74 this->log->debug(
"AbstractAuthzApiRequest::execute() ...HTTP request successfully executed");
94 const std::shared_ptr<::tenduke::log::Logger> log;
95 const std::shared_ptr<const ::tenduke::http::HTTPClient> http;
96 const std::shared_ptr<const ::tenduke::http::HTTPRequestAuthenticator> httpRequestAuthenticator;
97 const std::shared_ptr<const ::tenduke::http::HTTPResponseToException> throwException;
virtual T parseResponsePayload(const std::string &payload) const =0
Parses the response payload to tenduke::ee::licensing::LicenseCheckoutResponse.
virtual void buildRequestUrl(::tenduke::net::URLBuilder &url) const =0
Builds request URL.
AbstractAuthzApiRequest(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<::tenduke::log::Logger > &logger)
Constructs new instance.
Definition AbstractAuthzApiRequest.h:34
T execute() override
Executes the request.
Definition AbstractAuthzApiRequest.h:50
Licensing-related request.
Definition LicensingRequest.h:13
Very simple URL-builder.
Definition URLBuilder.h:19
Low-level client for licensing operations using 10Duke authz-API.
Definition AuthzLicensingClient.h:13
Classes, functions and globals related to 10Duke Enterprise licensing.
Definition AuthzLicensingClient.h:13
Classes, functions and globals of 10Duke Enterprise C++ Client.
Definition APIRequest.h:4
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4