Model::TweetからHttpPostにエラーハンドリングを移動した(#67)
This commit is contained in:
@@ -11,10 +11,9 @@ void Destroy::id(const std::string _id) {
|
||||
CocoaTweet::API::Model::Tweet Destroy::process(
|
||||
std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
|
||||
CocoaTweet::API::Model::Tweet tweet;
|
||||
HttpPost::process(_oauth,
|
||||
[&tweet](const unsigned int _responseCode, const std::string& _rsv) {
|
||||
tweet = CocoaTweet::API::Model::Tweet::parse(_responseCode, _rsv);
|
||||
});
|
||||
HttpPost::process(_oauth, [&tweet](const std::string& _rcv) {
|
||||
tweet = CocoaTweet::API::Model::Tweet::parse(_rcv);
|
||||
});
|
||||
return tweet;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
#include <iostream>
|
||||
|
||||
namespace CocoaTweet::API::Statuses {
|
||||
Retweet::Retweet(){}
|
||||
Retweet::Retweet() {}
|
||||
|
||||
void Retweet::id(const std::string& _id){
|
||||
void Retweet::id(const std::string& _id) {
|
||||
contentType_ = "application/x-www-form-urlencoded";
|
||||
url_ = "https://api.twitter.com/1.1/statuses/retweet/" + _id + ".json";
|
||||
}
|
||||
}
|
||||
|
||||
CocoaTweet::API::Model::Tweet Retweet::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth){
|
||||
CocoaTweet::API::Model::Tweet Retweet::process(
|
||||
std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
|
||||
CocoaTweet::API::Model::Tweet tweet;
|
||||
HttpPost::process(_oauth,
|
||||
[&tweet](const unsigned int _responseCode, const std::string& _rcv) {
|
||||
tweet = CocoaTweet::API::Model::Tweet(_responseCode, _rcv);
|
||||
});
|
||||
HttpPost::process(_oauth, [&tweet](const std::string& _rcv) {
|
||||
tweet = CocoaTweet::API::Model::Tweet(_rcv);
|
||||
});
|
||||
|
||||
return tweet;
|
||||
}
|
||||
}
|
||||
} // namespace CocoaTweet::API::Statuses
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
#include <cocoatweet/api/model/tweet.h>
|
||||
|
||||
namespace CocoaTweet::API::Statuses {
|
||||
class Retweet : public CocoaTweet::API::Interface::HttpPost{
|
||||
public:
|
||||
Retweet();
|
||||
class Retweet : public CocoaTweet::API::Interface::HttpPost {
|
||||
public:
|
||||
Retweet();
|
||||
|
||||
void id(const std::string& _id);
|
||||
void id(const std::string& _id);
|
||||
|
||||
CocoaTweet::API::Model::Tweet process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
|
||||
};
|
||||
}
|
||||
CocoaTweet::API::Model::Tweet process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
|
||||
};
|
||||
} // namespace CocoaTweet::API::Statuses
|
||||
|
||||
#endif
|
||||
@@ -79,9 +79,10 @@ CocoaTweet::API::Model::Tweet Status::Retweet(const std::string& _id) const {
|
||||
return retweet.process(oauth_);
|
||||
}
|
||||
|
||||
std::vector<CocoaTweet::API::Model::Tweet> Status::UserTimeline(const std::string& _screenName) const{
|
||||
std::vector<CocoaTweet::API::Model::Tweet> Status::UserTimeline(
|
||||
const std::string& _screenName) const {
|
||||
CocoaTweet::API::Statuses::UserTimeline userTimeline;
|
||||
userTimeline.screenName(_screenName);
|
||||
return userTimeline.process(oauth_);
|
||||
userTimeline.screenName(_screenName);
|
||||
return userTimeline.process(oauth_);
|
||||
}
|
||||
} // namespace CocoaTweet::API::Statuses
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
|
||||
CocoaTweet::API::Model::Tweet Retweet(const std::string& _id) const;
|
||||
|
||||
std::vector<CocoaTweet::API::Model::Tweet> UserTimeline(const std::string& _screenName) const;
|
||||
std::vector<CocoaTweet::API::Model::Tweet> UserTimeline(const std::string& _screenName) const;
|
||||
|
||||
private:
|
||||
Options defaultOpt_;
|
||||
|
||||
@@ -55,10 +55,9 @@ void Update::failDMCommands(bool _fail) {
|
||||
|
||||
CocoaTweet::API::Model::Tweet Update::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
|
||||
CocoaTweet::API::Model::Tweet tweet;
|
||||
HttpPost::process(_oauth,
|
||||
[&tweet](const unsigned int _responseCode, const std::string& _rsv) {
|
||||
tweet = CocoaTweet::API::Model::Tweet::parse(_responseCode, _rsv);
|
||||
});
|
||||
HttpPost::process(_oauth, [&tweet](const std::string& _rcv) {
|
||||
tweet = CocoaTweet::API::Model::Tweet::parse(_rcv);
|
||||
});
|
||||
return tweet;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@ void UserTimeline::screenName(const std::string& _screenName) {
|
||||
std::vector<CocoaTweet::API::Model::Tweet> UserTimeline::process(
|
||||
std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
|
||||
std::vector<CocoaTweet::API::Model::Tweet> tweet;
|
||||
HttpGet::process(_oauth, [&tweet](const unsigned int _responseCode, const std::string& _rsv) {
|
||||
auto json = nlohmann::json::parse(_rsv);
|
||||
HttpGet::process(_oauth, [&tweet](const std::string& _rcv) {
|
||||
auto json = nlohmann::json::parse(_rcv);
|
||||
for (auto j : json) {
|
||||
tweet.push_back(CocoaTweet::API::Model::Tweet::parse(_responseCode, j.dump()));
|
||||
tweet.push_back(CocoaTweet::API::Model::Tweet::parse(j.dump()));
|
||||
std::cout << j.dump() << std::endl;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user