10Duke Scale C++ Client
All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
OAuthTokenRequest.h
1#ifndef TENDUKE_OAUTH_OAUTHTOKENREQUEST_H
2#define TENDUKE_OAUTH_OAUTHTOKENREQUEST_H
3
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"
11
12#include <memory>
13
14namespace tenduke { namespace oauth {
15
16
23{
24public:
33 std::unique_ptr<tenduke::http::HTTPCall> httpCall,
34 const std::shared_ptr<const tenduke::json::JSONParser> &jsonParser,
35 const std::shared_ptr<tenduke::time::Clock> &clock,
36 const std::shared_ptr<const tenduke::http::HTTPResponseToException> &throwException
37 );
38
47 std::unique_ptr<tenduke::http::HTTPCall> httpCall,
48 const std::shared_ptr<const tenduke::json::JSONParser> &jsonParser,
49 const std::shared_ptr<tenduke::time::Clock> &clock
50 );
51
52 virtual ~OAuthTokenRequest() = default;
53
68 virtual std::unique_ptr<tenduke::oauth::OAuthTokenResponse> execute() const;
69
73 static std::unique_ptr<OAuthTokenRequest> create(
74 const std::string &tokenEndpointUrl,
75 const std::map<std::string, std::string> &parameters,
76 const std::shared_ptr<const tenduke::http::HTTPClient> &httpClient,
77 const std::shared_ptr<const tenduke::json::JSONParser> &jsonParser,
78 const std::shared_ptr<tenduke::time::Clock> &clock
79 );
80
81protected:
87 virtual std::unique_ptr<tenduke::json::JSONObject> parseResponseBody(const std::string &responsePayload) const;
88
94 virtual std::unique_ptr<tenduke::oauth::OAuthTokenResponse> toResponse(const std::string &responsePayload) const;
95
96private:
97 const std::unique_ptr<tenduke::http::HTTPCall> httpCall;
98 const std::shared_ptr<const tenduke::json::JSONParser> parseJSON;
99 const std::shared_ptr<const tenduke::time::Clock> clock;
100 const std::shared_ptr<const tenduke::http::HTTPResponseToException> throwException;
101};
102
103
104}}
105
106#endif // TENDUKE_OAUTH_OAUTHTOKENREQUEST_H
OAuth token request.
Definition OAuthTokenRequest.h:23
virtual std::unique_ptr< tenduke::oauth::OAuthTokenResponse > toResponse(const std::string &responsePayload) const
Converts the response body to OAuthTokenResponse.
Definition OAuthTokenRequest.cpp:81
static std::unique_ptr< OAuthTokenRequest > create(const std::string &tokenEndpointUrl, const std::map< std::string, std::string > &parameters, 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:44
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:21
virtual std::unique_ptr< tenduke::oauth::OAuthTokenResponse > execute() const
Executes the token request.
Definition OAuthTokenRequest.cpp:69
virtual std::unique_ptr< tenduke::json::JSONObject > parseResponseBody(const std::string &responsePayload) const
Parses the response body to JSON.
Definition OAuthTokenRequest.cpp:116
OAuth services.
Definition AccessTokenRequestAuthenticator.h:8
Root for classes, functions and globals of 10Duke C++ Client.
Definition BackendConfiguration.h:7