1#ifndef TENDUKE_EE_LICENSING_AUTZHAPI_ABSTRACTLICENSETOKENAUTHZAPIREQUEST_H
2#define TENDUKE_EE_LICENSING_AUTZHAPI_ABSTRACTLICENSETOKENAUTHZAPIREQUEST_H
4#include "./AbstractAuthzApiRequest.h"
5#include "../../LicenseTokenParser.h"
7#include "http/HTTPClient.h"
8#include "http/HTTPRequestAuthenticator.h"
9#include "http/HTTPResponseToException.h"
15namespace tenduke {
namespace ee {
namespace licensing {
namespace authzapi {
37 const std::shared_ptr<const ::tenduke::http::HTTPClient> &httpClient,
38 const std::shared_ptr<const ::tenduke::http::HTTPRequestAuthenticator> &httpRequestAuthenticator,
39 const std::shared_ptr<const ::tenduke::http::HTTPResponseToException> &throwException,
40 const std::shared_ptr<const tenduke::ee::licensing::impl::LicenseTokenParser> &licenseTokenParser
42 , parseLicenseToken(licenseTokenParser)
55 std::map<std::string, ::tenduke::ee::licensing::Lease> items;
56 std::map<std::string, ::tenduke::ee::licensing::LicensingError> failedItems;
61 std::size_t payloadLength = payload.length();
62 for (
int i = 0; i < payloadLength; i++) {
63 if (payload.at(i) ==
'&') {
65 parseLicenseToken->from(payload.substr(startOfToken, i - startOfToken)),
74 if (startOfToken < payloadLength) {
76 parseLicenseToken->from(payload.substr(startOfToken)),
81 return {items, failedItems};
85 void handleParsedResult(
86 const ::tenduke::ee::licensing::impl::LeaseOrError &leaseOrError,
87 std::map<std::string, ::tenduke::ee::licensing::Lease> &items,
88 std::map<std::string, ::tenduke::ee::licensing::LicensingError> &failedItems
91 if (leaseOrError.isLease()) {
92 items.emplace(leaseOrError.lease.name, leaseOrError.lease);
95 failedItems.emplace(leaseOrError.error.getItemName(), leaseOrError.error);
100 const std::shared_ptr<const ::tenduke::ee::licensing::impl::LicenseTokenParser> parseLicenseToken;
Base class for authz-API HTTP requests.
Definition AbstractAuthzApiRequest.h:24
Base class for licensing requests, which return tokens.
Definition AbstractLicenseTokenAuthzApiRequest.h:25
T parseResponsePayload(const std::string &payload) const override
Parses the response payload.
Definition AbstractLicenseTokenAuthzApiRequest.h:53
AbstractLicenseTokenAuthzApiRequest(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::ee::licensing::impl::LicenseTokenParser > &licenseTokenParser)
Constructs new instance.g.
Definition AbstractLicenseTokenAuthzApiRequest.h:36
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4