This commit is contained in:
keita
2021-02-20 23:03:29 +09:00
parent 8600dff037
commit 788eda9d4a
6 changed files with 17 additions and 14 deletions
+4 -3
View File
@@ -3,14 +3,15 @@
namespace CocoaTweet::API::Favorites {
Create::Create() {
contentType_ = "application/x-www-form-urlencoded";
url_ = "https://api.twitter.com/1.1/favorites/create.json";
url_ = "https://api.twitter.com/1.1/favorites/create.json";
}
void Create::id(const std::string& _id) {
bodyParam_.insert_or_assign("id", _id);
}
void Create::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth){
postInterface::process(_oauth, [](const std::string& _srv){std::cout << _srv << std::endl;});
void Create::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
postInterface::process(_oauth,
[](const std::string& _srv) { std::cout << _srv << std::endl; });
}
} // namespace CocoaTweet::API::Favorites
+4 -3
View File
@@ -3,14 +3,15 @@
namespace CocoaTweet::API::Favorites {
Destroy::Destroy() {
contentType_ = "application/x-www-form-urlencoded";
url_ = "https://api.twitter.com/1.1/favorites/destroy.json";
url_ = "https://api.twitter.com/1.1/favorites/destroy.json";
}
void Destroy::id(const std::string& _id) {
bodyParam_.insert_or_assign("id", _id);
}
void Destroy::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth){
postInterface::process(_oauth, [](const std::string& _srv){std::cout << _srv << std::endl;});
void Destroy::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
postInterface::process(_oauth,
[](const std::string& _srv) { std::cout << _srv << std::endl; });
}
} // namespace CocoaTweet::API::Favorites
@@ -23,7 +23,7 @@ void postInterface::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth,
auto oauth = _oauth.lock();
auto oauthParam = oauth->oauthParam();
auto sigingParam = oauthParam;
if(contentType_ == "application/x-www-form-urlencoded"){
if (contentType_ == "application/x-www-form-urlencoded") {
for (const auto [k, v] : bodyParam_) {
sigingParam.insert_or_assign(k, v);
}
@@ -8,7 +8,6 @@
namespace CocoaTweet::API::Interface {
class postInterface {
public:
protected:
std::weak_ptr<CocoaTweet::OAuth::OAuth1> oauth_;
std::map<std::string, std::string> bodyParam_;
+4 -3
View File
@@ -4,11 +4,12 @@ namespace CocoaTweet::API::Statuses {
Destroy::Destroy() {}
void Destroy::id(const std::string _id) {
contentType_ = "application/x-www-form-urlencoded";
url_ = "https://api.twitter.com/1.1/statuses/destroy/" + _id + ".json";
url_ = "https://api.twitter.com/1.1/statuses/destroy/" + _id + ".json";
}
void Destroy::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth){
postInterface::process(_oauth, [](const std::string& _srv){std::cout << _srv << std::endl;});
void Destroy::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
postInterface::process(_oauth,
[](const std::string& _srv) { std::cout << _srv << std::endl; });
}
} // namespace CocoaTweet::API::Statuses
+4 -3
View File
@@ -3,15 +3,16 @@
namespace CocoaTweet::API::Statuses {
Update::Update() {
contentType_ = "application/x-www-form-urlencoded";
url_ = "https://api.twitter.com/1.1/statuses/update.json";
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){
postInterface::process(_oauth, [](const std::string& _srv){std::cout << _srv << std::endl;});
void Update::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
postInterface::process(_oauth,
[](const std::string& _srv) { std::cout << _srv << std::endl; });
}
} // namespace CocoaTweet::API::Statuses