diff --git a/src/cocoatweet/api/favorite/create.cc b/src/cocoatweet/api/favorite/create.cc index 8ba2e2e..5aff1ab 100644 --- a/src/cocoatweet/api/favorite/create.cc +++ b/src/cocoatweet/api/favorite/create.cc @@ -1,5 +1,5 @@ #include - +#include namespace CocoaTweet::API::Favorites { Create::Create() { contentType_ = "application/x-www-form-urlencoded"; @@ -11,7 +11,7 @@ void Create::id(const std::string& _id) { } void Create::process(std::weak_ptr _oauth) { - postInterface::process(_oauth, + HttpPost::process(_oauth, [](const std::string& _srv) { std::cout << _srv << std::endl; }); } } // namespace CocoaTweet::API::Favorites diff --git a/src/cocoatweet/api/favorite/create.h b/src/cocoatweet/api/favorite/create.h index b5707b9..9a22f88 100644 --- a/src/cocoatweet/api/favorite/create.h +++ b/src/cocoatweet/api/favorite/create.h @@ -1,10 +1,10 @@ #ifndef COCOATWEET_API_FAVORITE_CREATE_H_ #define COCOATWEET_API_FAVORITE_CREATE_H_ -#include +#include namespace CocoaTweet::API::Favorites { -class Create : public CocoaTweet::API::Interface::postInterface { +class Create : public CocoaTweet::API::Interface::HttpPost { public: Create(); void id(const std::string& _id); diff --git a/src/cocoatweet/api/favorite/destroy.cc b/src/cocoatweet/api/favorite/destroy.cc index ff0fb5e..5e9ce99 100644 --- a/src/cocoatweet/api/favorite/destroy.cc +++ b/src/cocoatweet/api/favorite/destroy.cc @@ -1,5 +1,5 @@ #include - +#include namespace CocoaTweet::API::Favorites { Destroy::Destroy() { contentType_ = "application/x-www-form-urlencoded"; @@ -11,7 +11,7 @@ void Destroy::id(const std::string& _id) { } void Destroy::process(std::weak_ptr _oauth) { - postInterface::process(_oauth, + HttpPost::process(_oauth, [](const std::string& _srv) { std::cout << _srv << std::endl; }); } } // namespace CocoaTweet::API::Favorites diff --git a/src/cocoatweet/api/favorite/destroy.h b/src/cocoatweet/api/favorite/destroy.h index cf408d3..809f4e7 100644 --- a/src/cocoatweet/api/favorite/destroy.h +++ b/src/cocoatweet/api/favorite/destroy.h @@ -1,10 +1,10 @@ #ifndef COCOATWEET_API_FAVORITE_DESTROY_H_ #define COCOATWEET_API_FAVORITE_DESTROY_H_ -#include +#include namespace CocoaTweet::API::Favorites { -class Destroy : public CocoaTweet::API::Interface::postInterface { +class Destroy : public CocoaTweet::API::Interface::HttpPost { public: Destroy(); void id(const std::string& _id); diff --git a/src/cocoatweet/api/interface/postInterface.cc b/src/cocoatweet/api/interface/httpPost.cc similarity index 93% rename from src/cocoatweet/api/interface/postInterface.cc rename to src/cocoatweet/api/interface/httpPost.cc index ad49ace..fe4272f 100644 --- a/src/cocoatweet/api/interface/postInterface.cc +++ b/src/cocoatweet/api/interface/httpPost.cc @@ -1,4 +1,4 @@ -#include +#include #include "cocoatweet/util/util.h" #include #include @@ -10,14 +10,14 @@ extern "C" { } namespace CocoaTweet::API::Interface { -size_t postInterface::curlCallback_(char* _ptr, size_t _size, size_t _nmemb, +size_t HttpPost::curlCallback_(char* _ptr, size_t _size, size_t _nmemb, std::string* _stream) { int realsize = _size * _nmemb; _stream->append(_ptr, realsize); return realsize; } -void postInterface::process(std::weak_ptr _oauth, +void HttpPost::process(std::weak_ptr _oauth, std::function _callback) { // エンドポイントへのパラメータにOAuthパラメータを付加して署名作成 auto oauth = _oauth.lock(); diff --git a/src/cocoatweet/api/interface/postInterface.h b/src/cocoatweet/api/interface/httpPost.h similarity index 93% rename from src/cocoatweet/api/interface/postInterface.h rename to src/cocoatweet/api/interface/httpPost.h index eeba218..faedf2b 100644 --- a/src/cocoatweet/api/interface/postInterface.h +++ b/src/cocoatweet/api/interface/httpPost.h @@ -3,11 +3,11 @@ #include #include "cocoatweet/oauth/oauth.h" -#include namespace CocoaTweet::API::Interface { -class postInterface { +class HttpPost { public: + protected: std::weak_ptr oauth_; std::map bodyParam_; diff --git a/src/cocoatweet/api/status/destroy.cc b/src/cocoatweet/api/status/destroy.cc index 61073ea..c7bb1f5 100644 --- a/src/cocoatweet/api/status/destroy.cc +++ b/src/cocoatweet/api/status/destroy.cc @@ -1,5 +1,5 @@ #include "cocoatweet/api/status/destroy.h" - +#include namespace CocoaTweet::API::Statuses { Destroy::Destroy() {} void Destroy::id(const std::string _id) { @@ -8,7 +8,7 @@ void Destroy::id(const std::string _id) { } void Destroy::process(std::weak_ptr _oauth) { - postInterface::process(_oauth, + HttpPost::process(_oauth, [](const std::string& _srv) { std::cout << _srv << std::endl; }); } diff --git a/src/cocoatweet/api/status/destroy.h b/src/cocoatweet/api/status/destroy.h index 45e9a4d..9a625a0 100644 --- a/src/cocoatweet/api/status/destroy.h +++ b/src/cocoatweet/api/status/destroy.h @@ -3,11 +3,11 @@ #include -#include "cocoatweet/api/interface/postInterface.h" +#include "cocoatweet/api/interface/httpPost.h" //#include "cocoatweet/oauth/oauth.h" namespace CocoaTweet::API::Statuses { -class Destroy : public CocoaTweet::API::Interface::postInterface { +class Destroy : public CocoaTweet::API::Interface::HttpPost { public: Destroy(); void id(const std::string _id); diff --git a/src/cocoatweet/api/status/update.cc b/src/cocoatweet/api/status/update.cc index 66f71d8..4c4fb40 100644 --- a/src/cocoatweet/api/status/update.cc +++ b/src/cocoatweet/api/status/update.cc @@ -1,4 +1,5 @@ #include "cocoatweet/api/status/update.h" +#include namespace CocoaTweet::API::Statuses { Update::Update() { @@ -11,7 +12,7 @@ void Update::status(const std::string _status) { } void Update::process(std::weak_ptr _oauth) { - postInterface::process(_oauth, + HttpPost::process(_oauth, [](const std::string& _srv) { std::cout << _srv << std::endl; }); } diff --git a/src/cocoatweet/api/status/update.h b/src/cocoatweet/api/status/update.h index 848046b..6f7cfb0 100644 --- a/src/cocoatweet/api/status/update.h +++ b/src/cocoatweet/api/status/update.h @@ -2,12 +2,11 @@ #define COCOATWEET_API_STATUSES_UPDATE_H_ #include - -#include "cocoatweet/api/interface/postInterface.h" +#include "cocoatweet/api/interface/httpPost.h" //#include "cocoatweet/oauth/oauth.h" namespace CocoaTweet::API::Statuses { -class Update : public CocoaTweet::API::Interface::postInterface { +class Update : public CocoaTweet::API::Interface::HttpPost { public: Update(); void status(const std::string _status);