diff --git a/src/cocoatweet/api/favorite/destroy.cc b/src/cocoatweet/api/favorite/destroy.cc new file mode 100644 index 0000000..967137e --- /dev/null +++ b/src/cocoatweet/api/favorite/destroy.cc @@ -0,0 +1,11 @@ +#include + +namespace CocoaTweet::API::Favorites { +Destroy::Destroy() { + url_ = "https://api.twitter.com/1.1/favorites/destroy.json"; +} + +void Destroy::id(const std::string& _id) { + bodyParam_.insert_or_assign("id", _id); +} +} // namespace CocoaTweet::API::Favorites diff --git a/src/cocoatweet/api/favorite/destroy.h b/src/cocoatweet/api/favorite/destroy.h new file mode 100644 index 0000000..423a916 --- /dev/null +++ b/src/cocoatweet/api/favorite/destroy.h @@ -0,0 +1,16 @@ +#ifndef COCOATWEET_API_FAVORITE_DESTROY_H_ +#define COCOATWEET_API_FAVORITE_DESTROY_H_ + +#include + +namespace CocoaTweet::API::Favorites { +class Destroy : public CocoaTweet::API::Interface::postInterface { +public: + Destroy(); + void id(const std::string& _id); + +private: +}; +} // namespace CocoaTweet::API::Favorites + +#endif diff --git a/src/cocoatweet/api/favorite/favorite.cc b/src/cocoatweet/api/favorite/favorite.cc index 6d8737d..e0e1a1b 100644 --- a/src/cocoatweet/api/favorite/favorite.cc +++ b/src/cocoatweet/api/favorite/favorite.cc @@ -2,6 +2,7 @@ #include "cocoatweet/api/favorite/favorite.h" #include "cocoatweet/api/favorite/create.h" +#include "cocoatweet/api/favorite/destroy.h" namespace CocoaTweet::API::Favorites { Favorite::Favorite(std::shared_ptr _oauth) { @@ -13,4 +14,10 @@ void Favorite::Create(const std::string& _id) const { create.id(_id); create.process(oauth_, [](std::string _rcv) { std::cout << _rcv << std::endl; }); } + +void Favorite::Destroy(const std::string& _id) const { + CocoaTweet::API::Favorites::Destroy destroy; + destroy.id(_id); + destroy.process(oauth_, [](std::string _rcv) { std::cout << _rcv << std::endl; }); +} } // namespace CocoaTweet::API::Favorites diff --git a/src/cocoatweet/api/favorite/favorite.h b/src/cocoatweet/api/favorite/favorite.h index 33ff8db..eae9ae8 100644 --- a/src/cocoatweet/api/favorite/favorite.h +++ b/src/cocoatweet/api/favorite/favorite.h @@ -10,6 +10,7 @@ public: Favorite() = default; Favorite(std::shared_ptr _oauth); void Create(const std::string& _id) const; + void Destroy(const std::string& _id) const; }; } // namespace CocoaTweet::API::Favorites diff --git a/src/main.cc b/src/main.cc index 4007667..3646a6c 100644 --- a/src/main.cc +++ b/src/main.cc @@ -12,7 +12,6 @@ auto main() -> int { // accessToken, // accessTokenSecret); - // also can generate Key object from JSON file // CocoaTweet::OAuth::Key key = CocoaTweet::OAuth::Key::fromJsonFile("api_key.json"); @@ -22,4 +21,5 @@ auto main() -> int { // Now, you can use a twitter api // api.status().Update("Hello Twitter World from Cocoa Twitter Library"); // api.favorite().Create("tweet id you want to fav."); + // api.favorite().Destroy("tweet id you want to un_fav."); }