10Duke Scale C++ Client
Loading...
Searching...
No Matches
tenduke::se::licensing::rest::AbstractAPIRequestMixin< T > Class Template Referenceabstract

#include <AbstractAPIRequestMixin.h>

Detailed Description

template<class T>
class tenduke::se::licensing::rest::AbstractAPIRequestMixin< T >

Abstract base-class with generic implementation for 10Duke Scale API requests.

This class implements generic framework for simple API requests, mostly GET-requests. In most cases it is enough for the concrete request to implement JSON-deserialization and URL-building.

Template Parameters
Ttype of the response
Inheritance diagram for tenduke::se::licensing::rest::AbstractAPIRequestMixin< T >:
tenduke::se::licensing::rest::AbstractPagingAPIRequest<::tenduke::se::licensing::LicenseConsumerClientBindingStatus > tenduke::se::licensing::rest::AbstractPagingAPIRequest< std::vector< Licensee > > tenduke::se::licensing::rest::AbstractPagingAPIRequest<::tenduke::se::licensing::LicenseConsumerLicensesStatus > tenduke::se::licensing::rest::AbstractPagingAPIRequest<::tenduke::se::licensing::LicenseKeyLicensesStatus > tenduke::se::licensing::rest::AbstractPagingAPIRequest< T > tenduke::se::licensing::rest::DefaultDescribeLicenseConsumerClientBindingsRequest tenduke::se::licensing::rest::DefaultDescribeLicenseConsumerLicenseesRequest tenduke::se::licensing::rest::DefaultDescribeLicenseConsumerLicensesRequest tenduke::se::licensing::rest::DefaultDescribeLicenseKeyRequest

Public Member Functions

 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.
 

Protected Member Functions

virtual T executeRequest ()
 Executes the request.
 
virtual T fromJSON (const std::string &responseBody) const =0
 Converts the response body from JSON to the response type.
 
virtual void buildUrl (::tenduke::net::URLBuilder &urlBuilder) const
 Builds the request URL.
 
virtual ::tenduke::http::HTTPRequestBuildersetHeaders (::tenduke::http::HTTPRequestBuilder &request) const
 Sets additional headers.
 

Protected Attributes

const std::string baseUrl
 Base-URL for the request.
 
const std::shared_ptr< const ::tenduke::http::HTTPClienthttp
 HTTP-client to execute the request.
 
const std::shared_ptr< const ::tenduke::http::HTTPRequestAuthenticatorhttpRequestAuthenticator
 For authenticating the request.
 
const std::shared_ptr< const ::tenduke::http::HTTPResponseToExceptionthrowException
 Service to throw exceptions based on HTTP status codes.
 
const std::shared_ptr< const ::tenduke::json::JSONParserparseJSON
 For parsing the response payload.
 

Constructor & Destructor Documentation

◆ AbstractAPIRequestMixin()

template<class T >
tenduke::se::licensing::rest::AbstractAPIRequestMixin< T >::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 
)
inline

Constructs new instance.

Parameters
baseUrl-
httpClient-
httpRequestAuthenticator-
throwException-
jsonParser-

Member Function Documentation

◆ buildUrl()

◆ executeRequest()

template<class T >
virtual T tenduke::se::licensing::rest::AbstractAPIRequestMixin< T >::executeRequest ( )
inlineprotectedvirtual

Executes the request.

Returns
-

◆ fromJSON()

◆ setHeaders()

Sets additional headers.

Parameters
request-
Returns
-

Member Data Documentation

◆ baseUrl

template<class T >
const std::string tenduke::se::licensing::rest::AbstractAPIRequestMixin< T >::baseUrl
protected

Base-URL for the request.

The implementation may add e.g. query parameters to this.

◆ httpRequestAuthenticator

template<class T >
const std::shared_ptr<const ::tenduke::http::HTTPRequestAuthenticator> tenduke::se::licensing::rest::AbstractAPIRequestMixin< T >::httpRequestAuthenticator
protected

For authenticating the request.

Optional.


The documentation for this class was generated from the following file: