format
This commit is contained in:
@@ -9,7 +9,7 @@ API::API(CocoaTweet::OAuth::Key _key) {
|
||||
directMessage_ = DirectMessages::DirectMessage(oauth_);
|
||||
}
|
||||
|
||||
const std::string& API::generateBearerToken() const{
|
||||
const std::string& API::generateBearerToken() const {
|
||||
return oauth_->generateBearerToken();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ void HttpGet::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth,
|
||||
auto url = url_;
|
||||
|
||||
// エンドポイントへのパラメータにOAuthパラメータを付加して署名作成
|
||||
auto oauth = _oauth.lock();
|
||||
auto oauth = _oauth.lock();
|
||||
// auto oauthParam = oauth->oauthParam();
|
||||
// auto sigingParam = oauthParam;
|
||||
// if (contentType_ == "application/x-www-form-urlencoded") {
|
||||
@@ -40,7 +40,6 @@ void HttpGet::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth,
|
||||
// // 作成した署名をエンドポイントへのパラメータ及びOAuthパラメータに登録
|
||||
// oauthParam.merge(signature);
|
||||
|
||||
|
||||
// // ヘッダの構築
|
||||
// std::string oauthHeader = "authorization: OAuth ";
|
||||
// {
|
||||
@@ -53,7 +52,7 @@ void HttpGet::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth,
|
||||
auto oauthHeader = std::string();
|
||||
if (contentType_ == "application/x-www-form-urlencoded") {
|
||||
oauthHeader = oauth->calculateAuthHeader(bodyParam_, "GET", url_);
|
||||
}else{
|
||||
} else {
|
||||
oauthHeader = oauth->calculateAuthHeader({}, "GET", url_);
|
||||
}
|
||||
|
||||
@@ -105,7 +104,7 @@ void HttpGet::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth,
|
||||
exit(1);
|
||||
}
|
||||
|
||||
std::cout << rcv << std::endl;
|
||||
std::cout << rcv << std::endl;
|
||||
if ((responseCode / 100) == 4) {
|
||||
auto j = nlohmann::json::parse(rcv);
|
||||
auto error = j["errors"][0]["code"];
|
||||
@@ -118,17 +117,15 @@ std::cout << rcv << std::endl;
|
||||
throw CocoaTweet::Exception::TweetNotFoundException(message.get<std::string>().c_str());
|
||||
} else if (error.get<int>() == 32) {
|
||||
throw CocoaTweet::Exception::AuthenticateException(message.get<std::string>().c_str());
|
||||
}else if(error.get<int>() == 89){
|
||||
} else if (error.get<int>() == 89) {
|
||||
throw CocoaTweet::Exception::TokenInvalidException(message.get<std::string>().c_str());
|
||||
}else if (error.get<int>() == 187) {
|
||||
} else if (error.get<int>() == 187) {
|
||||
throw CocoaTweet::Exception::TweetDuplicateException(message.get<std::string>().c_str());
|
||||
} else if (error.get<int>() == 88 || error.get<int>() == 185) {
|
||||
throw CocoaTweet::Exception::RateLimitException(message.get<std::string>().c_str());
|
||||
} else if (error.get<int>() == 186) {
|
||||
throw CocoaTweet::Exception::TweetTooLongException(message.get<std::string>().c_str());
|
||||
}
|
||||
else{
|
||||
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ void HttpPost::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth,
|
||||
throw CocoaTweet::Exception::TweetNotFoundException(message.get<std::string>().c_str());
|
||||
} else if (error.get<int>() == 32) {
|
||||
throw CocoaTweet::Exception::AuthenticateException(message.get<std::string>().c_str());
|
||||
}else if(error.get<int>() == 89){
|
||||
} else if (error.get<int>() == 89) {
|
||||
throw CocoaTweet::Exception::TokenInvalidException(message.get<std::string>().c_str());
|
||||
} else if (error.get<int>() == 187) {
|
||||
throw CocoaTweet::Exception::TweetDuplicateException(message.get<std::string>().c_str());
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
namespace CocoaTweet::API::Model {
|
||||
Tweet Tweet::parse(const std::string& _json) {
|
||||
auto j = nlohmann::json::parse(_json);
|
||||
auto j = nlohmann::json::parse(_json);
|
||||
Tweet tweet;
|
||||
|
||||
tweet.id(j["id_str"]);
|
||||
@@ -11,7 +11,7 @@ Tweet Tweet::parse(const std::string& _json) {
|
||||
tweet.text(j["text"]);
|
||||
tweet.source(j["source"]);
|
||||
|
||||
tweet.user(CocoaTweet::API::Model::User(j["user"].dump()));
|
||||
tweet.user(CocoaTweet::API::Model::User(j["user"].dump()));
|
||||
|
||||
return tweet;
|
||||
}
|
||||
|
||||
@@ -10,26 +10,24 @@ CocoaTweet::API::Model::User User::parse(const std::string& _json) {
|
||||
return user;
|
||||
}
|
||||
|
||||
void User::id(const std::string& _id){
|
||||
id_ = _id;
|
||||
void User::id(const std::string& _id) {
|
||||
id_ = _id;
|
||||
}
|
||||
|
||||
void User::name(const std::string& _name){
|
||||
name_ = _name;
|
||||
void User::name(const std::string& _name) {
|
||||
name_ = _name;
|
||||
}
|
||||
|
||||
void User::screenName(const std::string& _screen){
|
||||
screenName_ = _screen;
|
||||
void User::screenName(const std::string& _screen) {
|
||||
screenName_ = _screen;
|
||||
}
|
||||
|
||||
void User::location(const std::string& _location){
|
||||
location_ = _location;
|
||||
void User::location(const std::string& _location) {
|
||||
location_ = _location;
|
||||
}
|
||||
|
||||
const std::string& User::id() const{
|
||||
return id_;
|
||||
const std::string& User::id() const {
|
||||
return id_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace CocoaTweet::API::Model
|
||||
|
||||
@@ -25,36 +25,35 @@ public:
|
||||
|
||||
void id(const std::string& _id);
|
||||
void name(const std::string& _name);
|
||||
void screenName(const std::string& _screen);
|
||||
void location(const std::string& _location);
|
||||
void url(const std::string& _url);
|
||||
void description(const std::string& _description);
|
||||
void protectedUser(const bool _protected);
|
||||
void follower(const long _follower);
|
||||
void follow(const long _follow);
|
||||
void listed(const long _listed);
|
||||
void favorite(const long _favorite);
|
||||
void tweet(const long _tweet);
|
||||
void createdAt(const std::string& _created);
|
||||
void bannerUrl(const std::string& _banner);
|
||||
void iconUrl(const std::string& _icon);
|
||||
|
||||
void screenName(const std::string& _screen);
|
||||
void location(const std::string& _location);
|
||||
void url(const std::string& _url);
|
||||
void description(const std::string& _description);
|
||||
void protectedUser(const bool _protected);
|
||||
void follower(const long _follower);
|
||||
void follow(const long _follow);
|
||||
void listed(const long _listed);
|
||||
void favorite(const long _favorite);
|
||||
void tweet(const long _tweet);
|
||||
void createdAt(const std::string& _created);
|
||||
void bannerUrl(const std::string& _banner);
|
||||
void iconUrl(const std::string& _icon);
|
||||
|
||||
const std::string& id() const;
|
||||
const std::string& name() const;
|
||||
const std::string& screenName() const;
|
||||
const std::string& location() const;
|
||||
const std::string& url() const;
|
||||
const std::string& description() const;
|
||||
bool protectedUser() const;
|
||||
long follower() const;
|
||||
long follow() const;
|
||||
long listed() const;
|
||||
long favorite() const;
|
||||
long tweet() const;
|
||||
const std::string& created() const;
|
||||
const std::string& banner() const;
|
||||
const std::string& icon() const;
|
||||
const std::string& name() const;
|
||||
const std::string& screenName() const;
|
||||
const std::string& location() const;
|
||||
const std::string& url() const;
|
||||
const std::string& description() const;
|
||||
bool protectedUser() const;
|
||||
long follower() const;
|
||||
long follow() const;
|
||||
long listed() const;
|
||||
long favorite() const;
|
||||
long tweet() const;
|
||||
const std::string& created() const;
|
||||
const std::string& banner() const;
|
||||
const std::string& icon() const;
|
||||
|
||||
private:
|
||||
std::string id_;
|
||||
@@ -73,6 +72,6 @@ private:
|
||||
std::string bannerUrl_;
|
||||
std::string iconUrl_;
|
||||
};
|
||||
}
|
||||
} // namespace CocoaTweet::API::Model
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user