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"
14namespace tenduke {
namespace ee {
namespace licensing {
namespace authzapi {
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
39 , httpRequestAuthenticator(httpRequestAuthenticator)
40 , throwException(throwException)
51 auto request = http->request();
52 auto urlBuilder = request.url();
54 std::string url = urlBuilder.buildString();
59 auto httpCall = request.get()
60 .authenticateWith(httpRequestAuthenticator)
63 auto httpResponse = httpCall->execute();
65 if (! httpResponse->isSuccessful()) {
66 throwException->basedOn(*httpResponse);
87 const std::shared_ptr<const ::tenduke::http::HTTPClient> http;
88 const std::shared_ptr<const ::tenduke::http::HTTPRequestAuthenticator> httpRequestAuthenticator;
89 const std::shared_ptr<const ::tenduke::http::HTTPResponseToException> throwException;
Base class for authz-API HTTP requests.
Definition AbstractAuthzApiRequest.h:24
virtual T execute() override
Executes the request.
Definition AbstractAuthzApiRequest.h:48
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)
Constructs new instance.
Definition AbstractAuthzApiRequest.h:34
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.
Licensing-related request.
Definition LicensingRequest.h:13
Very simple URL-builder.
Definition URLBuilder.h:19
void trace(const char *message)
Write message to global logger at TRACE-level.
Definition log.cpp:56
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4