favorites/destroyを叩くやつ

This commit is contained in:
keita
2021-02-18 16:46:15 +09:00
parent 055ee555b1
commit 10eb11f3f5
5 changed files with 36 additions and 1 deletions
+11
View File
@@ -0,0 +1,11 @@
#include <cocoatweet/api/favorite/destroy.h>
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
+16
View File
@@ -0,0 +1,16 @@
#ifndef COCOATWEET_API_FAVORITE_DESTROY_H_
#define COCOATWEET_API_FAVORITE_DESTROY_H_
#include <cocoatweet/api/interface/postInterface.h>
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
+7
View File
@@ -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<CocoaTweet::OAuth::OAuth1> _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
+1
View File
@@ -10,6 +10,7 @@ public:
Favorite() = default;
Favorite(std::shared_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
void Create(const std::string& _id) const;
void Destroy(const std::string& _id) const;
};
} // namespace CocoaTweet::API::Favorites
+1 -1
View File
@@ -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.");
}