各種Exceptionの用意(#53)
Tweetオブジェクトを仮実装(#54) Tweetオブジェクトのパースに当たり、httpPostのステータスコードを取得(#54) 各種オブジェクトにパースするためにhttpPostに渡すコールバックの引数を変更
This commit is contained in:
@@ -8,12 +8,12 @@ void Destroy::id(const std::string _id) {
|
||||
url_ = "https://api.twitter.com/1.1/statuses/destroy/" + _id + ".json";
|
||||
}
|
||||
|
||||
void Destroy::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
|
||||
CocoaTweet::API::Model::Tweet Destroy::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
|
||||
CocoaTweet::API::Model::Tweet tweet;
|
||||
HttpPost::process(_oauth, [&tweet](const std::string& _srv) {
|
||||
tweet = CocoaTweet::API::Model::Tweet::parse(100, _srv);
|
||||
HttpPost::process(_oauth, [&tweet](const unsigned int _responseCode, const std::string& _rsv) {
|
||||
tweet = CocoaTweet::API::Model::Tweet::parse(_responseCode, _rsv);
|
||||
});
|
||||
std::cout << "afw" << std::endl;
|
||||
return tweet;
|
||||
}
|
||||
|
||||
} // namespace CocoaTweet::API::Statuses
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <cocoatweet/api/interface/httpPost.h>
|
||||
#include <cocoatweet/api/model/tweet.h>
|
||||
|
||||
namespace CocoaTweet::API::Statuses {
|
||||
/// @brief class for using status/destroy:id endpoint
|
||||
@@ -19,7 +20,7 @@ public:
|
||||
/// @brief process request for endpoint
|
||||
/// @param[in] std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth : pointer to oauth object
|
||||
/// @param[out] none
|
||||
void process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
|
||||
CocoaTweet::API::Model::Tweet process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
|
||||
};
|
||||
} // namespace CocoaTweet::API::Statuses
|
||||
|
||||
|
||||
@@ -9,15 +9,15 @@ Status::Status(std::shared_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
|
||||
oauth_ = _oauth;
|
||||
}
|
||||
|
||||
void Status::Update(const std::string& _status) const {
|
||||
CocoaTweet::API::Model::Tweet Status::Update(const std::string& _status) const {
|
||||
CocoaTweet::API::Statuses::Update update;
|
||||
update.status(_status);
|
||||
update.process(oauth_);
|
||||
return update.process(oauth_);
|
||||
}
|
||||
|
||||
void Status::Destroy(const std::string& _id) const {
|
||||
CocoaTweet::API::Model::Tweet Status::Destroy(const std::string& _id) const {
|
||||
CocoaTweet::API::Statuses::Destroy destroy;
|
||||
destroy.id(_id);
|
||||
destroy.process(oauth_);
|
||||
return destroy.process(oauth_);
|
||||
}
|
||||
} // namespace CocoaTweet::API::Statuses
|
||||
|
||||
@@ -3,14 +3,15 @@
|
||||
|
||||
#include "cocoatweet/api/interface/groupInterface.h"
|
||||
#include "cocoatweet/oauth/oauth.h"
|
||||
#include <cocoatweet/api/model/tweet.h>
|
||||
|
||||
namespace CocoaTweet::API::Statuses {
|
||||
class Status : public groupInterface {
|
||||
public:
|
||||
Status() = default;
|
||||
Status(std::shared_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
|
||||
void Update(const std::string& _status) const;
|
||||
void Destroy(const std::string& _id) const;
|
||||
CocoaTweet::API::Model::Tweet Update(const std::string& _status) const;
|
||||
CocoaTweet::API::Model::Tweet Destroy(const std::string& _id) const;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -6,13 +6,18 @@ Update::Update() {
|
||||
contentType_ = "application/x-www-form-urlencoded";
|
||||
url_ = "https://api.twitter.com/1.1/statuses/update.json";
|
||||
}
|
||||
|
||||
void Update::status(const std::string _status) {
|
||||
status_ = _status;
|
||||
bodyParam_.insert_or_assign("status", status_);
|
||||
}
|
||||
|
||||
void Update::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
|
||||
HttpPost::process(_oauth, [](const std::string& _srv) { std::cout << _srv << std::endl; });
|
||||
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);
|
||||
});
|
||||
return tweet;
|
||||
}
|
||||
|
||||
} // namespace CocoaTweet::API::Statuses
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
#define COCOATWEET_API_STATUSES_UPDATE_H_
|
||||
|
||||
#include <memory>
|
||||
#include "cocoatweet/api/interface/httpPost.h"
|
||||
//#include "cocoatweet/oauth/oauth.h"
|
||||
#include <cocoatweet/api/interface/httpPost.h>
|
||||
#include <cocoatweet/api/model/tweet.h>
|
||||
|
||||
namespace CocoaTweet::API::Statuses {
|
||||
class Update : public CocoaTweet::API::Interface::HttpPost {
|
||||
public:
|
||||
Update();
|
||||
void status(const std::string _status);
|
||||
void process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
|
||||
CocoaTweet::API::Model::Tweet process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
|
||||
|
||||
private:
|
||||
std::string status_;
|
||||
|
||||
Reference in New Issue
Block a user