1#ifndef TENDUKE_OAUTH_OAUTHTOKENREQUEST_H
2#define TENDUKE_OAUTH_OAUTHTOKENREQUEST_H
4#include "./OAuthTokenResponse.h"
5#include "http/HTTPCall.h"
6#include "http/HTTPClient.h"
7#include "http/HTTPResponseToException.h"
8#include "json/JSONObject.h"
9#include "json/JSONParser.h"
10#include "time/Clock.h"
36 std::unique_ptr<tenduke::http::HTTPCall> httpCall,
37 const std::shared_ptr<const tenduke::json::JSONParser> &jsonParser,
38 const std::shared_ptr<tenduke::time::Clock> &clock,
39 const std::shared_ptr<const tenduke::http::HTTPResponseToException> &throwException
50 std::unique_ptr<tenduke::http::HTTPCall> httpCall,
51 const std::shared_ptr<const tenduke::json::JSONParser> &jsonParser,
52 const std::shared_ptr<tenduke::time::Clock> &clock
71 virtual std::unique_ptr<tenduke::oauth::OAuthTokenResponse>
execute()
const;
76 static std::unique_ptr<OAuthTokenRequest>
create(
77 const std::string &tokenEndpointUrl,
78 const std::map<std::string, std::string> ¶meters,
79 const std::shared_ptr<const tenduke::http::HTTPClient> &httpClient,
80 const std::shared_ptr<const tenduke::json::JSONParser> &jsonParser,
81 const std::shared_ptr<tenduke::time::Clock> &clock
90 virtual std::unique_ptr<tenduke::json::JSONObject>
parseResponseBody(
const std::string &responsePayload)
const;
97 virtual std::unique_ptr<tenduke::oauth::OAuthTokenResponse>
toResponse(
const std::string &responsePayload)
const;
100 const std::unique_ptr<tenduke::http::HTTPCall> httpCall;
101 const std::shared_ptr<const tenduke::json::JSONParser> parseJSON;
102 const std::shared_ptr<const tenduke::time::Clock> clock;
103 const std::shared_ptr<const tenduke::http::HTTPResponseToException> throwException;
OAuthTokenRequest(std::unique_ptr< tenduke::http::HTTPCall > httpCall, const std::shared_ptr< const tenduke::json::JSONParser > &jsonParser, const std::shared_ptr< tenduke::time::Clock > &clock, const std::shared_ptr< const tenduke::http::HTTPResponseToException > &throwException)
Constructs new instance.
Definition OAuthTokenRequest.cpp:25
virtual std::unique_ptr< tenduke::oauth::OAuthTokenResponse > toResponse(const std::string &responsePayload) const
Converts the response body to OAuthTokenResponse.
Definition OAuthTokenRequest.cpp:155
static std::unique_ptr< OAuthTokenRequest > create(const std::string &tokenEndpointUrl, const std::map< std::string, std::string > ¶meters, const std::shared_ptr< const tenduke::http::HTTPClient > &httpClient, const std::shared_ptr< const tenduke::json::JSONParser > &jsonParser, const std::shared_ptr< tenduke::time::Clock > &clock)
Factory method to create the request.
Definition OAuthTokenRequest.cpp:48
OAuthTokenRequest(std::unique_ptr< tenduke::http::HTTPCall > httpCall, const std::shared_ptr< const tenduke::json::JSONParser > &jsonParser, const std::shared_ptr< tenduke::time::Clock > &clock, const std::shared_ptr< const tenduke::http::HTTPResponseToException > &throwException)
Constructs new instance.
Definition OAuthTokenRequest.cpp:25
virtual std::unique_ptr< tenduke::oauth::OAuthTokenResponse > execute() const
Executes the token request.
Definition OAuthTokenRequest.cpp:73
virtual std::unique_ptr< tenduke::json::JSONObject > parseResponseBody(const std::string &responsePayload) const
Parses the response body to JSON.
Definition OAuthTokenRequest.cpp:212
static const std::int64_t MAX_EXPIRES_IN_S
Maximum expires_in of a token response, 10 years: a larger value is limited to this.
Definition OAuthTokenRequest.h:26
OAuth services.
Definition AccessTokenRequestAuthenticator.h:8
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4