code format
This commit is contained in:
@@ -2,32 +2,33 @@
|
||||
#include <cocoatweet/util/util.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace CocoaTweet::API::OAuth1{
|
||||
AccessToken::AccessToken(){
|
||||
contentType_ = "application/x-www-form-urlencoded";
|
||||
url_ = "https://api.twitter.com/oauth/access_token";
|
||||
}
|
||||
namespace CocoaTweet::API::OAuth1 {
|
||||
AccessToken::AccessToken() {
|
||||
contentType_ = "application/x-www-form-urlencoded";
|
||||
url_ = "https://api.twitter.com/oauth/access_token";
|
||||
}
|
||||
|
||||
void AccessToken::oauthVerifier(const std::string& _verifier){
|
||||
bodyParam_.insert_or_assign("oauth_verifier", _verifier);
|
||||
}
|
||||
void AccessToken::oauthVerifier(const std::string& _verifier) {
|
||||
bodyParam_.insert_or_assign("oauth_verifier", _verifier);
|
||||
}
|
||||
|
||||
void AccessToken::oauthToken(const CocoaTweet::API::Model::OAuthToken _token){
|
||||
oauthToken_ = _token;
|
||||
}
|
||||
void AccessToken::oauthToken(const CocoaTweet::API::Model::OAuthToken _token) {
|
||||
oauthToken_ = _token;
|
||||
}
|
||||
|
||||
const CocoaTweet::API::Model::OAuthToken AccessToken::process(std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth){
|
||||
CocoaTweet::API::Model::OAuthToken oauthToken;
|
||||
HttpPost::process(_oauth, [&oauthToken](const std::string& _rcv){
|
||||
auto mp = CocoaTweet::Util::parse(_rcv, '&', '=');
|
||||
if(mp.count("oauth_token")){
|
||||
oauthToken.oauthToken(mp.at("oauth_token"));
|
||||
}
|
||||
if(mp.count("oauth_token_secret")){
|
||||
oauthToken.oauthTokenSecret(mp.at("oauth_token_secret"));
|
||||
}
|
||||
std::cout << _rcv << std::endl;
|
||||
});
|
||||
return oauthToken;
|
||||
const CocoaTweet::API::Model::OAuthToken AccessToken::process(
|
||||
std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth) {
|
||||
CocoaTweet::API::Model::OAuthToken oauthToken;
|
||||
HttpPost::process(_oauth, [&oauthToken](const std::string& _rcv) {
|
||||
auto mp = CocoaTweet::Util::parse(_rcv, '&', '=');
|
||||
if (mp.count("oauth_token")) {
|
||||
oauthToken.oauthToken(mp.at("oauth_token"));
|
||||
}
|
||||
}
|
||||
if (mp.count("oauth_token_secret")) {
|
||||
oauthToken.oauthTokenSecret(mp.at("oauth_token_secret"));
|
||||
}
|
||||
std::cout << _rcv << std::endl;
|
||||
});
|
||||
return oauthToken;
|
||||
}
|
||||
} // namespace CocoaTweet::API::OAuth1
|
||||
@@ -3,18 +3,20 @@
|
||||
|
||||
#include <cocoatweet/api/interface/httpPost.h>
|
||||
#include <cocoatweet/api/model/oauthToken.h>
|
||||
namespace CocoaTweet::API::OAuth1{
|
||||
class AccessToken: public CocoaTweet::API::Interface::HttpPost {
|
||||
namespace CocoaTweet::API::OAuth1 {
|
||||
class AccessToken : public CocoaTweet::API::Interface::HttpPost {
|
||||
private:
|
||||
CocoaTweet::API::Model::OAuthToken oauthToken_;
|
||||
CocoaTweet::API::Model::OAuthToken oauthToken_;
|
||||
|
||||
public:
|
||||
AccessToken();
|
||||
AccessToken();
|
||||
|
||||
void oauthVerifier(const std::string& _verifier);
|
||||
void oauthToken(const CocoaTweet::API::Model::OAuthToken _token);
|
||||
void oauthVerifier(const std::string& _verifier);
|
||||
void oauthToken(const CocoaTweet::API::Model::OAuthToken _token);
|
||||
|
||||
const CocoaTweet::API::Model::OAuthToken process(std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth) ;
|
||||
};
|
||||
}
|
||||
const CocoaTweet::API::Model::OAuthToken process(
|
||||
std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth);
|
||||
};
|
||||
} // namespace CocoaTweet::API::OAuth1
|
||||
|
||||
#endif
|
||||
@@ -3,31 +3,33 @@
|
||||
#include <iostream>
|
||||
#include <cocoatweet/util/util.h>
|
||||
|
||||
namespace CocoaTweet::API::OAuth1{
|
||||
Authorize::Authorize(){
|
||||
contentType_ = "application/x-www-form-urlencoded";
|
||||
url_ = "https://api.twitter.com/oauth/authorize";
|
||||
}
|
||||
namespace CocoaTweet::API::OAuth1 {
|
||||
Authorize::Authorize() {
|
||||
contentType_ = "application/x-www-form-urlencoded";
|
||||
url_ = "https://api.twitter.com/oauth/authorize";
|
||||
}
|
||||
|
||||
void Authorize::oauthToken(const std::string& _oauthToken){
|
||||
bodyParam_.insert_or_assign("oauth_token", _oauthToken);
|
||||
}
|
||||
void Authorize::oauthToken(const std::string& _oauthToken) {
|
||||
bodyParam_.insert_or_assign("oauth_token", _oauthToken);
|
||||
}
|
||||
|
||||
void Authorize::forceLogin(const bool _forceLogin){
|
||||
bodyParam_.insert_or_assign("force_login", std::to_string(static_cast<int>(_forceLogin)));
|
||||
}
|
||||
void Authorize::forceLogin(const bool _forceLogin) {
|
||||
bodyParam_.insert_or_assign("force_login", std::to_string(static_cast<int>(_forceLogin)));
|
||||
}
|
||||
|
||||
void Authorize::screenName(const std::string& _screenName){
|
||||
bodyParam_.insert_or_assign("screen_name", _screenName);
|
||||
}
|
||||
void Authorize::screenName(const std::string& _screenName) {
|
||||
bodyParam_.insert_or_assign("screen_name", _screenName);
|
||||
}
|
||||
|
||||
const std::string Authorize::process(std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> __unused__) {
|
||||
std::vector<std::string> tmp;
|
||||
std::string query = "";
|
||||
for (const auto& [key, value] : bodyParam_) {
|
||||
tmp.push_back(key + "=" + value);
|
||||
query = CocoaTweet::Util::join(tmp, "&");
|
||||
}
|
||||
return url_ + "?" + query;;
|
||||
}
|
||||
}
|
||||
const std::string Authorize::process(
|
||||
std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> __unused__) {
|
||||
std::vector<std::string> tmp;
|
||||
std::string query = "";
|
||||
for (const auto& [key, value] : bodyParam_) {
|
||||
tmp.push_back(key + "=" + value);
|
||||
query = CocoaTweet::Util::join(tmp, "&");
|
||||
}
|
||||
return url_ + "?" + query;
|
||||
;
|
||||
}
|
||||
} // namespace CocoaTweet::API::OAuth1
|
||||
@@ -2,19 +2,20 @@
|
||||
#define COCOATWEET_API_OAUTH1_AUTHORIZE_H
|
||||
|
||||
#include <cocoatweet/api/interface/httpPost.h>
|
||||
namespace CocoaTweet::API::OAuth1{
|
||||
class Authorize: public CocoaTweet::API::Interface::HttpPost {
|
||||
namespace CocoaTweet::API::OAuth1 {
|
||||
class Authorize : public CocoaTweet::API::Interface::HttpPost {
|
||||
public:
|
||||
Authorize();
|
||||
Authorize();
|
||||
|
||||
void oauthToken(const std::string& _oauthToken);
|
||||
void oauthToken(const std::string& _oauthToken);
|
||||
|
||||
void forceLogin(const bool _forceLogin);
|
||||
void forceLogin(const bool _forceLogin);
|
||||
|
||||
void screenName(const std::string& _screenName);
|
||||
void screenName(const std::string& _screenName);
|
||||
|
||||
const std::string process(std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> __unused__) ;
|
||||
};
|
||||
}
|
||||
const std::string process(
|
||||
std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> __unused__);
|
||||
};
|
||||
} // namespace CocoaTweet::API::OAuth1
|
||||
|
||||
#endif
|
||||
@@ -2,34 +2,36 @@
|
||||
#include <cocoatweet/authentication/authenticate.h>
|
||||
|
||||
namespace CocoaTweet::API::OAuth1 {
|
||||
OAuth::OAuth(std::shared_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth){
|
||||
oauth_ = _oauth;
|
||||
}
|
||||
OAuth::OAuth(std::shared_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth) {
|
||||
oauth_ = _oauth;
|
||||
}
|
||||
|
||||
CocoaTweet::API::Model::OAuthToken OAuth::requestToken(const std::string& _oauthCallback) const{
|
||||
auto key = oauth_.lock()->key();
|
||||
key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A);
|
||||
auto oauth = std::make_shared<CocoaTweet::Authentication::OAuth1>(key);
|
||||
CocoaTweet::API::Model::OAuthToken OAuth::requestToken(
|
||||
const std::string& _oauthCallback) const {
|
||||
auto key = oauth_.lock()->key();
|
||||
key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A);
|
||||
auto oauth = std::make_shared<CocoaTweet::Authentication::OAuth1>(key);
|
||||
|
||||
CocoaTweet::API::OAuth1::RequestToken requestToken;
|
||||
requestToken.oauthCallback(_oauthCallback);
|
||||
return requestToken.process(oauth);
|
||||
}
|
||||
CocoaTweet::API::OAuth1::RequestToken requestToken;
|
||||
requestToken.oauthCallback(_oauthCallback);
|
||||
return requestToken.process(oauth);
|
||||
}
|
||||
|
||||
const std::string OAuth::authorize(const CocoaTweet::API::Model::OAuthToken _oauthToken) const{
|
||||
CocoaTweet::API::OAuth1::Authorize authorize;
|
||||
authorize.oauthToken(_oauthToken.oauthToken());
|
||||
return authorize.process(oauth_);
|
||||
}
|
||||
const std::string OAuth::authorize(const CocoaTweet::API::Model::OAuthToken _oauthToken) const {
|
||||
CocoaTweet::API::OAuth1::Authorize authorize;
|
||||
authorize.oauthToken(_oauthToken.oauthToken());
|
||||
return authorize.process(oauth_);
|
||||
}
|
||||
|
||||
const CocoaTweet::API::Model::OAuthToken OAuth::accessToken(const CocoaTweet::API::Model::OAuthToken _oauthToken, const std::string _verifier) const{
|
||||
auto key = oauth_.lock()->key();
|
||||
key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A);
|
||||
key.accessToken(_oauthToken.oauthToken());
|
||||
key.accessTokenSecret(_oauthToken.oauthTokenSecret());
|
||||
auto oauth = std::make_shared<CocoaTweet::Authentication::OAuth1>(key);
|
||||
CocoaTweet::API::OAuth1::AccessToken accessToken;
|
||||
accessToken.oauthVerifier(_verifier);
|
||||
return accessToken.process(oauth);
|
||||
}
|
||||
} // namespace CocoaTweet::API::Statuses
|
||||
const CocoaTweet::API::Model::OAuthToken OAuth::accessToken(
|
||||
const CocoaTweet::API::Model::OAuthToken _oauthToken, const std::string _verifier) const {
|
||||
auto key = oauth_.lock()->key();
|
||||
key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A);
|
||||
key.accessToken(_oauthToken.oauthToken());
|
||||
key.accessTokenSecret(_oauthToken.oauthTokenSecret());
|
||||
auto oauth = std::make_shared<CocoaTweet::Authentication::OAuth1>(key);
|
||||
CocoaTweet::API::OAuth1::AccessToken accessToken;
|
||||
accessToken.oauthVerifier(_verifier);
|
||||
return accessToken.process(oauth);
|
||||
}
|
||||
} // namespace CocoaTweet::API::OAuth1
|
||||
|
||||
@@ -15,16 +15,17 @@ class OAuth : public groupInterface {
|
||||
public:
|
||||
/// @brief primary constructor
|
||||
OAuth() = default;
|
||||
|
||||
|
||||
/// @brief constructor which finally should to be called.
|
||||
/// @param[in] std::shared_ptr<CocoaTweet::Authentication::AuthenticatorBase> : pointer to OAuth object
|
||||
/// @param[in] std::shared_ptr<CocoaTweet::Authentication::AuthenticatorBase> : pointer to
|
||||
/// OAuth object
|
||||
OAuth(std::shared_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth);
|
||||
|
||||
CocoaTweet::API::Model::OAuthToken requestToken(const std::string& _oauthCallback) const;
|
||||
const std::string authorize(const CocoaTweet::API::Model::OAuthToken _oauthToken) const;
|
||||
const CocoaTweet::API::Model::OAuthToken accessToken(const CocoaTweet::API::Model::OAuthToken _oauthToken, const std::string _verifier) const;
|
||||
|
||||
const CocoaTweet::API::Model::OAuthToken accessToken(
|
||||
const CocoaTweet::API::Model::OAuthToken _oauthToken, const std::string _verifier) const;
|
||||
};
|
||||
} // namespace CocoaTweet::API::Statuses
|
||||
} // namespace CocoaTweet::API::OAuth1
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,28 +2,29 @@
|
||||
#include <cocoatweet/util/util.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace CocoaTweet::API::OAuth1{
|
||||
RequestToken::RequestToken(){
|
||||
contentType_ = "application/x-www-form-urlencoded";
|
||||
url_ = "https://api.twitter.com/oauth/request_token";
|
||||
}
|
||||
namespace CocoaTweet::API::OAuth1 {
|
||||
RequestToken::RequestToken() {
|
||||
contentType_ = "application/x-www-form-urlencoded";
|
||||
url_ = "https://api.twitter.com/oauth/request_token";
|
||||
}
|
||||
|
||||
void RequestToken::oauthCallback(const std::string& _oauthCallback){
|
||||
bodyParam_.insert_or_assign("oauth_callback", _oauthCallback);
|
||||
}
|
||||
void RequestToken::oauthCallback(const std::string& _oauthCallback) {
|
||||
bodyParam_.insert_or_assign("oauth_callback", _oauthCallback);
|
||||
}
|
||||
|
||||
CocoaTweet::API::Model::OAuthToken RequestToken::process(std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth){
|
||||
CocoaTweet::API::Model::OAuthToken oauthToken;
|
||||
HttpPost::process(_oauth, [&oauthToken](const std::string& _rcv){
|
||||
auto mp = CocoaTweet::Util::parse(_rcv, '&', '=');
|
||||
if(mp.count("oauth_token")){
|
||||
oauthToken.oauthToken(mp.at("oauth_token"));
|
||||
}
|
||||
if(mp.count("oauth_token_secret")){
|
||||
oauthToken.oauthTokenSecret(mp.at("oauth_token_secret"));
|
||||
}
|
||||
std::cout << _rcv << std::endl;
|
||||
});
|
||||
return oauthToken;
|
||||
CocoaTweet::API::Model::OAuthToken RequestToken::process(
|
||||
std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth) {
|
||||
CocoaTweet::API::Model::OAuthToken oauthToken;
|
||||
HttpPost::process(_oauth, [&oauthToken](const std::string& _rcv) {
|
||||
auto mp = CocoaTweet::Util::parse(_rcv, '&', '=');
|
||||
if (mp.count("oauth_token")) {
|
||||
oauthToken.oauthToken(mp.at("oauth_token"));
|
||||
}
|
||||
}
|
||||
if (mp.count("oauth_token_secret")) {
|
||||
oauthToken.oauthTokenSecret(mp.at("oauth_token_secret"));
|
||||
}
|
||||
std::cout << _rcv << std::endl;
|
||||
});
|
||||
return oauthToken;
|
||||
}
|
||||
} // namespace CocoaTweet::API::OAuth1
|
||||
@@ -4,14 +4,15 @@
|
||||
#include <cocoatweet/api/interface/httpPost.h>
|
||||
#include <cocoatweet/api/model/oauthToken.h>
|
||||
|
||||
namespace CocoaTweet::API::OAuth1{
|
||||
class RequestToken: public CocoaTweet::API::Interface::HttpPost {
|
||||
public:
|
||||
RequestToken();
|
||||
void oauthCallback(const std::string& _oauthCallback);
|
||||
namespace CocoaTweet::API::OAuth1 {
|
||||
class RequestToken : public CocoaTweet::API::Interface::HttpPost {
|
||||
public:
|
||||
RequestToken();
|
||||
void oauthCallback(const std::string& _oauthCallback);
|
||||
|
||||
CocoaTweet::API::Model::OAuthToken process(std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth);
|
||||
};
|
||||
}
|
||||
CocoaTweet::API::Model::OAuthToken process(
|
||||
std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth);
|
||||
};
|
||||
} // namespace CocoaTweet::API::OAuth1
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user