10Duke Scale C++ Client
Loading...
Searching...
No Matches
AbstractPagingAPIRequest.h
1#ifndef TENDUKE_SE_LICENSING_ABSTRACTPAGINGAPIREQUEST_H
2#define TENDUKE_SE_LICENSING_ABSTRACTPAGINGAPIREQUEST_H
3
4#include <utility>
5
6#include "./AbstractAPIRequestMixin.h"
7#include "../Paging.h"
8
9namespace tenduke { namespace se { namespace licensing { namespace rest {
10
15template<class T>
17{
18public:
29 const std::string &baseUrl
30 , const std::shared_ptr<const ::tenduke::http::HTTPClient> &httpClient
31 , const std::shared_ptr<const ::tenduke::http::HTTPRequestAuthenticator> &httpRequestAuthenticator
32 , const std::shared_ptr<const ::tenduke::http::HTTPResponseToException> &throwException
33 , const std::shared_ptr<const ::tenduke::json::JSONParser> &jsonParser
35 ) : ::tenduke::se::licensing::rest::AbstractAPIRequestMixin<T>(
37 , httpClient
40 , jsonParser
41 )
42 , paging(std::move(paging))
43 {}
44
45protected:
52 const override
53 {
54 if (paging.offset >= 0) {
55 request.header("offset", std::to_string(paging.offset));
56 }
57 if (paging.limit >= 0) {
58 request.header("limit", std::to_string(paging.limit));
59 }
60 request.header("order-by", (paging.orderBy));
61 if (paging.orderAsc) {
62 request.header("orderAsc", "true");
63 }
64 return request;
65 }
66
67private:
69};
70
71}}}}
72
73#endif //TENDUKE_SE_LICENSING_ABSTRACTPAGINGAPIREQUEST_H
Builds HTTPRequest.
Definition HTTPRequestBuilder.h:22
HTTPRequestBuilder & header(const std::string &name, const std::string &value, bool skipIfValueEmpty=true)
Adds header to the request.
Definition HTTPRequestBuilder.cpp:118
Paging-ocnfiguration for the REST-API.
Definition Paging.h:13
const std::int32_t limit
Number of items to retrieve.
Definition Paging.h:37
const bool orderAsc
Sort in ascending order?
Definition Paging.h:41
const std::int32_t offset
Start offset.
Definition Paging.h:35
const std::string orderBy
Field to sort by.
Definition Paging.h:39
A tenduke::se::APIRequest, which uses tenduke::oidc::OIDCSession to maintain request authorization.
Definition StatefulAPIRequest.h:27
Abstract base-class with generic implementation for 10Duke Scale API requests.
Definition AbstractAPIRequestMixin.h:26
const std::shared_ptr< const ::tenduke::http::HTTPResponseToException > throwException
Service to throw exceptions based on HTTP status codes.
Definition AbstractAPIRequestMixin.h:117
const std::string baseUrl
Base-URL for the request.
Definition AbstractAPIRequestMixin.h:108
const std::shared_ptr< const ::tenduke::http::HTTPRequestAuthenticator > httpRequestAuthenticator
For authenticating the request.
Definition AbstractAPIRequestMixin.h:114
Abstract base class for API-requests, which support paging.
Definition AbstractPagingAPIRequest.h:17
::tenduke::http::HTTPRequestBuilder & setHeaders(::tenduke::http::HTTPRequestBuilder &request) const override
Sets the paging headers to the request.
Definition AbstractPagingAPIRequest.h:51
AbstractPagingAPIRequest(const 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, ::tenduke::se::Paging paging)
Constructs new instance.
Definition AbstractPagingAPIRequest.h:28
Root for classes, functions and globals of 10Duke C++ Client.
Definition BackendConfiguration.h:7