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 a 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< T >

Public Member Functions

 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.
 

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::HTTPRequestBuilder & setHeaders (::tenduke::http::HTTPRequestBuilder &request) const
 Sets additional headers.
 

Protected Attributes

const ::tenduke::net::URL 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 ( 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 )
inline

Constructs a 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()

template<class T>
virtual::tenduke::http::HTTPRequestBuilder & tenduke::se::licensing::rest::AbstractAPIRequestMixin< T >::setHeaders ( ::tenduke::http::HTTPRequestBuilder & request) const
inlineprotected

Sets additional headers.

Parameters
request-
Returns
-

Member Data Documentation

◆ baseUrl

template<class T>
const ::tenduke::net::URL 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: