direct_maggages/event/newをたたくやつ
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
#include <cocoatweet/api/directMessage/new.h>
|
||||||
|
#include <cocoatweet/util/util.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace CocoaTweet::API::DirectMessages{
|
||||||
|
New::New(){
|
||||||
|
url_ = "https://api.twitter.com/1.1/direct_messages/events/new.json";
|
||||||
|
contentType_ = "application/json";
|
||||||
|
|
||||||
|
nlohmann::json tmp;
|
||||||
|
tmp["type"] = "message_create";
|
||||||
|
tmp["message_create"] = nlohmann::json::object();
|
||||||
|
tmp["message_create"]["target"] = nlohmann::json::object();
|
||||||
|
tmp["message_create"]["message_data"] = nlohmann::json::object();
|
||||||
|
json_["event"] = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void New::recipient(const std::string& _id){
|
||||||
|
json_["event"]["message_create"]["target"]["recipient_id"] = std::stol(_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void New::message(const std::string& _message){
|
||||||
|
json_["event"]["message_create"]["message_data"]["text"] = _message;
|
||||||
|
}
|
||||||
|
|
||||||
|
void New::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth){
|
||||||
|
bodyParam_.insert_or_assign("data", json_.dump());
|
||||||
|
HttpPost::process(_oauth, [](const std::string& _rcv){});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef COCOATWEET_API_DIRECTMESSAGE_NEW_H_
|
||||||
|
#define COCOATWEET_API_DIRECTMESSAGE_NEW_H_
|
||||||
|
|
||||||
|
#include <cocoatweet/api/interface/httpPost.h>
|
||||||
|
#include <cocoatweet/api/model/tweet.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <utility>
|
||||||
|
#include <memory>
|
||||||
|
#include "nlohmann/json.hpp"
|
||||||
|
|
||||||
|
namespace CocoaTweet::API::DirectMessages {
|
||||||
|
/// @brief class for using statuses/update endpoint
|
||||||
|
class New : public CocoaTweet::API::Interface::HttpPost {
|
||||||
|
public:
|
||||||
|
New();
|
||||||
|
void recipient(const std::string& _id);
|
||||||
|
void message(const std::string& _message);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @brief process request for endpoint
|
||||||
|
/// @param[in] std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth : pointer to oauth object
|
||||||
|
/// @param[out] CocoaTweet::API::Model::Tweet : request result
|
||||||
|
void process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string status_;
|
||||||
|
nlohmann::json json_;
|
||||||
|
};
|
||||||
|
} // namespace CocoaTweet::API::Statuses
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user