1#ifndef TENDUKE_SE_LICENSING_REST_ABSTRACTAPIREQUEST_H
2#define TENDUKE_SE_LICENSING_REST_ABSTRACTAPIREQUEST_H
4#include "http/HTTPClient.h"
5#include "http/HTTPRequestAuthenticator.h"
6#include "http/HTTPResponseToException.h"
7#include "json/JSONParser.h"
34 const ::tenduke::net::URL &
baseUrl
35 ,
const std::shared_ptr<const ::tenduke::http::HTTPClient> &httpClient
37 ,
const std::shared_ptr<const ::tenduke::http::HTTPResponseToException> &
throwException
38 ,
const std::shared_ptr<const ::tenduke::json::JSONParser> &jsonParser
65 auto response =
http->call(request.
build())->execute();
67 if (! response->isSuccessful()) {
71 return fromJSON(response->getPayloadAsString());
80 virtual T
fromJSON(
const std::string &responseBody)
const = 0;
108 const std::shared_ptr<const ::tenduke::http::HTTPClient>
http;
114 const std::shared_ptr<const ::tenduke::http::HTTPResponseToException>
throwException;
117 const std::shared_ptr<const ::tenduke::json::JSONParser>
parseJSON;
Builds HTTPRequest.
Definition HTTPRequestBuilder.h:23
std::unique_ptr< HTTPRequest > build()
Builds the request.
Definition HTTPRequestBuilder.cpp:26
HTTPRequestBuilder & authenticateWith(const std::shared_ptr< const tenduke::http::HTTPRequestAuthenticator > &requestAuthenticator)
Sets the request authenticator.
Definition HTTPRequestBuilder.cpp:108
tenduke::net::URLBuilder createURL() const
Starts URL-building.
Definition HTTPRequestBuilder.cpp:158
HTTPRequestBuilder & url(const std::string &url)
Sets the request URL.
Definition HTTPRequestBuilder.cpp:96
Very simple URL-builder.
Definition URLBuilder.h:23
URLBuilder & baseURL(const ::tenduke::net::URL &url)
Sets the base URL.
Definition URLBuilder.cpp:54
::tenduke::net::URL build()
Builds the URL.
Definition URLBuilder.cpp:25
Abstract base-class with generic implementation for 10Duke Scale API requests.
Definition AbstractAPIRequestMixin.h:23
const std::shared_ptr< const ::tenduke::http::HTTPResponseToException > throwException
Service to throw exceptions based on HTTP status codes.
Definition AbstractAPIRequestMixin.h:114
virtual T executeRequest()
Executes the request.
Definition AbstractAPIRequestMixin.h:53
virtual::tenduke::http::HTTPRequestBuilder & setHeaders(::tenduke::http::HTTPRequestBuilder &request) const
Sets additional headers.
Definition AbstractAPIRequestMixin.h:97
const std::shared_ptr< const ::tenduke::http::HTTPClient > http
HTTP-client to execute the request.
Definition AbstractAPIRequestMixin.h:108
virtual T fromJSON(const std::string &responseBody) const =0
Converts the response body from JSON to the response type.
AbstractAPIRequestMixin(const ::tenduke::net::URL &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 a new instance.
Definition AbstractAPIRequestMixin.h:33
const std::shared_ptr< const ::tenduke::http::HTTPRequestAuthenticator > httpRequestAuthenticator
For authenticating the request.
Definition AbstractAPIRequestMixin.h:111
const std::shared_ptr< const ::tenduke::json::JSONParser > parseJSON
For parsing the response payload.
Definition AbstractAPIRequestMixin.h:117
const ::tenduke::net::URL baseUrl
Base-URL for the request.
Definition AbstractAPIRequestMixin.h:105
virtual void buildUrl(::tenduke::net::URLBuilder &urlBuilder) const
Builds the request URL.
Definition AbstractAPIRequestMixin.h:86
Low-level services for performing licensing REST-requests.
Definition DefaultDescribeLicenseConsumerClientBindingsRequest.h:9
Licensing operations for 10Duke Scale.
Definition LicenseConsumerClientBindingStatus.h:8
Classes, functions and globals of 10Duke Scale C++ Client.
Definition AbstractClientFactory.h:16
Root for classes, functions and globals of 10Duke C++ Client.
Definition AbstractClientFactory.h:16