コメント書いたり

This commit is contained in:
keita
2021-03-11 21:40:10 +09:00
parent 16daa46810
commit d2425d009d
11 changed files with 127 additions and 63 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ public:
/// @brief process request for endpoint
/// @param[in] std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth : pointer to oauth object
/// @param[out] none
/// @param[out] CocoaTweet::API::Model::Tweet : request result
CocoaTweet::API::Model::Tweet process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
};
} // namespace CocoaTweet::API::Statuses
+11 -10
View File
@@ -13,43 +13,44 @@ CocoaTweet::API::Model::Tweet Status::Update(const std::string& _status) const {
return update.process(oauth_);
}
CocoaTweet::API::Model::Tweet Status::Update(const std::string& _status, const Options _options) const{
CocoaTweet::API::Model::Tweet Status::Update(const std::string& _status,
const Options _options) const {
CocoaTweet::API::Statuses::Update update;
update.status(_status);
if(_options.replyToStatusId != defaultOpt_.replyToStatusId){
if (_options.replyToStatusId != defaultOpt_.replyToStatusId) {
update.replyToStatusId(_options.replyToStatusId);
}
if(_options.autoPopulateReplyMetaData != defaultOpt_.autoPopulateReplyMetaData){
if (_options.autoPopulateReplyMetaData != defaultOpt_.autoPopulateReplyMetaData) {
update.autoPopulateReplyMetaData(_options.autoPopulateReplyMetaData);
}
if(_options.excludeReplyUserId != defaultOpt_.excludeReplyUserId){
if (_options.excludeReplyUserId != defaultOpt_.excludeReplyUserId) {
update.excludeReplyUserId(_options.excludeReplyUserId);
}
if(_options.attachmentUrl != defaultOpt_.attachmentUrl){
if (_options.attachmentUrl != defaultOpt_.attachmentUrl) {
update.attachmentUrl(_options.attachmentUrl);
}
if(_options.coord != defaultOpt_.coord){
if (_options.coord != defaultOpt_.coord) {
update.coord(_options.coord);
}
if(_options.displayCoord != defaultOpt_.displayCoord){
if (_options.displayCoord != defaultOpt_.displayCoord) {
update.displayCoord(_options.displayCoord);
}
if(_options.trimUser != defaultOpt_.trimUser){
if (_options.trimUser != defaultOpt_.trimUser) {
update.trimUser(_options.trimUser);
}
if(_options.enableDMCommands != defaultOpt_.enableDMCommands){
if (_options.enableDMCommands != defaultOpt_.enableDMCommands) {
update.enableDMCommands(_options.enableDMCommands);
}
if(_options.failDMCommands != defaultOpt_.failDMCommands){
if (_options.failDMCommands != defaultOpt_.failDMCommands) {
update.failDMCommands(_options.failDMCommands);
}
+40 -13
View File
@@ -7,33 +7,60 @@
#include <vector>
#include <utility>
namespace CocoaTweet::API::Statuses {
/// @brief Entory point for statuses/*
class Status : public groupInterface {
public:
struct Options {
std::string replyToStatusId;
bool autoPopulateReplyMetaData = false;
std::vector<std::string> excludeReplyUserId;
std::string attachmentUrl;
std::pair<std::string, std::string> coord;
bool displayCoord = false;
bool trimUser = false;
bool enableDMCommands = false;
bool failDMCommands = true;
};
struct Options{
std::string replyToStatusId;
bool autoPopulateReplyMetaData = false;
std::vector<std::string> excludeReplyUserId;
std::string attachmentUrl;
std::pair<std::string, std::string> coord;
bool displayCoord = false;
bool trimUser = false;
bool enableDMCommands = false;
bool failDMCommands = true;
};
/// @brief primary constructor to allow for create NON-INITIALIZED object
Status() = default;
/// @brief constructor which finally should to be called.
/// @param[in] std::shared_ptr<CocoaTweet::OAuth::OAuth1> : pointer to OAuth object
Status(std::shared_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
/// @brief send request to statuses/update with specified status
/// @details this function throws CocoaTweet::Exception::* if something happen
/// @param[in] const std::string& : tweet text
/// @param[out] CocoaTweet::API::Model::Tweet : Tweet result
CocoaTweet::API::Model::Tweet Update(const std::string& _status) const;
CocoaTweet::API::Model::Tweet Update(const std::string& _status, const Options _options) const;
/// @brief send request to statuses/update with specified status
/// @details this function throws CocoaTweet::Exception::* if something happen
/// @param[in] const std::string& : tweet text
/// @param[in] const CocoaTweet::API::Statuses::Status::Options option : status update options
/// for more parameters
/// @param[out] CocoaTweet::API::Model::Tweet : Tweet result
CocoaTweet::API::Model::Tweet Update(const std::string& _status,
const Options _options) const;
/// @brief send request to statuses/update with specified status
/// @details this function throws CocoaTweet::Exception::* if something happen
/// @param[in] const std::string& : tweet text
/// @param[in] std::vector<std::string> _mediaId : media id which posted with tweet
/// @param[out] CocoaTweet::API::Model::Tweet : Tweet result
CocoaTweet::API::Model::Tweet Update(const std::string& _status,
std::vector<std::string> _mediaId) const;
/// @brief send request to statuses/destroy with specified id
/// @details this function throws CocoaTweet::Exception::* if something happen
/// @param[in] const std::string& : tweet id which should be delete
/// @param[out] CocoaTweet::API::Model::Tweet : Destroy result
CocoaTweet::API::Model::Tweet Destroy(const std::string& _id) const;
private:
Options defaultOpt_;
Options defaultOpt_;
};
} // namespace CocoaTweet::API::Statuses
+9 -9
View File
@@ -16,40 +16,40 @@ void Update::mediaId(const std::vector<std::string> _media) {
bodyParam_.insert_or_assign("media_ids", CocoaTweet::Util::join(_media, ","));
}
void Update::replyToStatusId(const std::string _reply){
void Update::replyToStatusId(const std::string _reply) {
bodyParam_.insert_or_assign("in_reply_to_status_id", _reply);
}
void Update::autoPopulateReplyMetaData(bool _meta){
void Update::autoPopulateReplyMetaData(bool _meta) {
bodyParam_.insert_or_assign("auto_populate_reply_metadata", std::to_string(_meta));
}
void Update::excludeReplyUserId(const std::vector<std::string> _ex){
void Update::excludeReplyUserId(const std::vector<std::string> _ex) {
bodyParam_.insert_or_assign("exclude_reply_user_ids", CocoaTweet::Util::join(_ex, ","));
}
void Update::attachmentUrl(const std::string _url){
void Update::attachmentUrl(const std::string _url) {
bodyParam_.insert_or_assign("attachment_url", _url);
}
void Update::coord(std::pair<std::string, std::string> _coord){
void Update::coord(std::pair<std::string, std::string> _coord) {
bodyParam_.insert_or_assign("lat", _coord.first);
bodyParam_.insert_or_assign("long", _coord.second);
}
void Update::displayCoord(bool _disp){
void Update::displayCoord(bool _disp) {
bodyParam_.insert_or_assign("display_coordinates", std::to_string(_disp));
}
void Update::trimUser(bool _trim){
void Update::trimUser(bool _trim) {
bodyParam_.insert_or_assign("trim_user", std::to_string(_trim));
}
void Update::enableDMCommands(bool _enable){
void Update::enableDMCommands(bool _enable) {
bodyParam_.insert_or_assign("enable_dmcommands", std::to_string(_enable));
}
void Update::failDMCommands(bool _fail){
void Update::failDMCommands(bool _fail) {
bodyParam_.insert_or_assign("fail_dmcommands", std::to_string(_fail));
}
+14 -5
View File
@@ -8,9 +8,15 @@
#include <memory>
namespace CocoaTweet::API::Statuses {
/// @brief class for using statuses/update endpoint
class Update : public CocoaTweet::API::Interface::HttpPost {
public:
/// @brief primary constructor
Update();
/// @brief set tweet text for sending request to statuses/update
/// @param[in] const std::string _status : tweet text
/// @param[out] none
void status(const std::string _status);
void mediaId(const std::vector<std::string> _media);
@@ -23,16 +29,19 @@ public:
void attachmentUrl(const std::string _url);
void coord(std::pair<std::string, std::string> _coord);
void coord(std::pair<std::string, std::string> _coord);
void displayCoord(bool _disp);
void displayCoord(bool _disp);
void trimUser(bool _trim);
void trimUser(bool _trim);
void enableDMCommands(bool _enable);
void enableDMCommands(bool _enable);
void failDMCommands(bool _fail);
void failDMCommands(bool _fail);
/// @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
CocoaTweet::API::Model::Tweet process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
private: