diff --git a/src/cocoatweet/api/favorite/create.cc b/src/cocoatweet/api/favorite/create.cc index 1d4cc83..7ecb523 100644 --- a/src/cocoatweet/api/favorite/create.cc +++ b/src/cocoatweet/api/favorite/create.cc @@ -1,4 +1,5 @@ #include +#include namespace CocoaTweet::API::Favorites { Create::Create() { @@ -10,8 +11,12 @@ void Create::id(const std::string& _id) { bodyParam_.insert_or_assign("id", _id); } -void Create::process(std::weak_ptr _oauth) { - HttpPost::process(_oauth, [](const unsigned int _, const std::string& _srv) { +CocoaTweet::API::Model::Tweet Create::process(std::weak_ptr _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); }); + + return tweet; } } // namespace CocoaTweet::API::Favorites diff --git a/src/cocoatweet/api/favorite/create.h b/src/cocoatweet/api/favorite/create.h index 9a22f88..a8f7388 100644 --- a/src/cocoatweet/api/favorite/create.h +++ b/src/cocoatweet/api/favorite/create.h @@ -2,13 +2,14 @@ #define COCOATWEET_API_FAVORITE_CREATE_H_ #include +#include namespace CocoaTweet::API::Favorites { class Create : public CocoaTweet::API::Interface::HttpPost { public: Create(); void id(const std::string& _id); - void process(std::weak_ptr _oauth); + CocoaTweet::API::Model::Tweet process(std::weak_ptr _oauth); private: }; diff --git a/src/cocoatweet/api/favorite/destroy.cc b/src/cocoatweet/api/favorite/destroy.cc index 23d4a6d..e26ae0b 100644 --- a/src/cocoatweet/api/favorite/destroy.cc +++ b/src/cocoatweet/api/favorite/destroy.cc @@ -1,4 +1,5 @@ #include +#include namespace CocoaTweet::API::Favorites { Destroy::Destroy() { @@ -10,8 +11,12 @@ void Destroy::id(const std::string& _id) { bodyParam_.insert_or_assign("id", _id); } -void Destroy::process(std::weak_ptr _oauth) { - HttpPost::process(_oauth, [](const unsigned int _, const std::string& _srv) { +CocoaTweet::API::Model::Tweet Destroy::process(std::weak_ptr _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); }); + + return tweet; } } // namespace CocoaTweet::API::Favorites diff --git a/src/cocoatweet/api/favorite/destroy.h b/src/cocoatweet/api/favorite/destroy.h index 809f4e7..719a22b 100644 --- a/src/cocoatweet/api/favorite/destroy.h +++ b/src/cocoatweet/api/favorite/destroy.h @@ -2,13 +2,14 @@ #define COCOATWEET_API_FAVORITE_DESTROY_H_ #include +#include namespace CocoaTweet::API::Favorites { class Destroy : public CocoaTweet::API::Interface::HttpPost { public: Destroy(); void id(const std::string& _id); - void process(std::weak_ptr _oauth); + CocoaTweet::API::Model::Tweet process(std::weak_ptr _oauth); private: }; diff --git a/src/cocoatweet/api/favorite/favorite.cc b/src/cocoatweet/api/favorite/favorite.cc index 99c0898..71631ff 100644 --- a/src/cocoatweet/api/favorite/favorite.cc +++ b/src/cocoatweet/api/favorite/favorite.cc @@ -7,15 +7,15 @@ Favorite::Favorite(std::shared_ptr _oauth) { oauth_ = _oauth; } -void Favorite::Create(const std::string& _id) const { +CocoaTweet::API::Model::Tweet Favorite::Create(const std::string& _id) const { CocoaTweet::API::Favorites::Create create; create.id(_id); - create.process(oauth_); + return create.process(oauth_); } -void Favorite::Destroy(const std::string& _id) const { +CocoaTweet::API::Model::Tweet Favorite::Destroy(const std::string& _id) const { CocoaTweet::API::Favorites::Destroy destroy; destroy.id(_id); - destroy.process(oauth_); + return destroy.process(oauth_); } } // namespace CocoaTweet::API::Favorites diff --git a/src/cocoatweet/api/favorite/favorite.h b/src/cocoatweet/api/favorite/favorite.h index eae9ae8..1f6ed6c 100644 --- a/src/cocoatweet/api/favorite/favorite.h +++ b/src/cocoatweet/api/favorite/favorite.h @@ -3,14 +3,15 @@ #include "cocoatweet/api/interface/groupInterface.h" #include "cocoatweet/oauth/oauth.h" +#include namespace CocoaTweet::API::Favorites { class Favorite : public groupInterface { public: Favorite() = default; Favorite(std::shared_ptr _oauth); - void Create(const std::string& _id) const; - void Destroy(const std::string& _id) const; + CocoaTweet::API::Model::Tweet Create(const std::string& _id) const; + CocoaTweet::API::Model::Tweet Destroy(const std::string& _id) const; }; } // namespace CocoaTweet::API::Favorites