statuses/updateのエンドポイントのオプションを書いた
This commit is contained in:
@@ -12,7 +12,7 @@ you can use these endpoint
|
|||||||
- statuses/destroy/:id
|
- statuses/destroy/:id
|
||||||
- favorites/create
|
- favorites/create
|
||||||
- favorites/destroy
|
- favorites/destroy
|
||||||
|
- media/upload(support: jpg, jpeg, png, gif, mp4)
|
||||||
# Dependency
|
# Dependency
|
||||||
- libcurl(openssl version)
|
- libcurl(openssl version)
|
||||||
- libssl
|
- libssl
|
||||||
@@ -114,6 +114,11 @@ CocoaTweet::API::API api(key);
|
|||||||
// Post a tweet
|
// Post a tweet
|
||||||
api.status().Update("Hello, World!!\nTweet from Cocoa Twitter Library");
|
api.status().Update("Hello, World!!\nTweet from Cocoa Twitter Library");
|
||||||
|
|
||||||
|
// Upload a media
|
||||||
|
// auto media1 = api.media().Upload("path/to/file/image.jpeg");
|
||||||
|
// auto media2 = api.media().Upload("path/to/file/image2.png");
|
||||||
|
// api.status().Update("Upload media from Cocoa Twitter Library", {media1.id(), media2.id()});
|
||||||
|
|
||||||
// Delete a tweet
|
// Delete a tweet
|
||||||
api.status().Destroy("tweet id");
|
api.status().Destroy("tweet id");
|
||||||
|
|
||||||
@@ -123,3 +128,5 @@ api.favorite().Create("tweet id");
|
|||||||
// un Fav. a tweet
|
// un Fav. a tweet
|
||||||
api.favorite().Destroy("tweet id");
|
api.favorite().Destroy("tweet id");
|
||||||
```
|
```
|
||||||
|
|
||||||
|
donate by BitCoin : bc1qhpm8tmq72scqpl2ccemcf0ktfjg4rsu73e99tz
|
||||||
@@ -13,6 +13,49 @@ CocoaTweet::API::Model::Tweet Status::Update(const std::string& _status) const {
|
|||||||
return update.process(oauth_);
|
return update.process(oauth_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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){
|
||||||
|
update.replyToStatusId(_options.replyToStatusId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_options.autoPopulateReplyMetaData != defaultOpt_.autoPopulateReplyMetaData){
|
||||||
|
update.autoPopulateReplyMetaData(_options.autoPopulateReplyMetaData);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_options.excludeReplyUserId != defaultOpt_.excludeReplyUserId){
|
||||||
|
update.excludeReplyUserId(_options.excludeReplyUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_options.attachmentUrl != defaultOpt_.attachmentUrl){
|
||||||
|
update.attachmentUrl(_options.attachmentUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_options.coord != defaultOpt_.coord){
|
||||||
|
update.coord(_options.coord);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_options.displayCoord != defaultOpt_.displayCoord){
|
||||||
|
update.displayCoord(_options.displayCoord);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_options.trimUser != defaultOpt_.trimUser){
|
||||||
|
update.trimUser(_options.trimUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_options.enableDMCommands != defaultOpt_.enableDMCommands){
|
||||||
|
update.enableDMCommands(_options.enableDMCommands);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_options.failDMCommands != defaultOpt_.failDMCommands){
|
||||||
|
update.failDMCommands(_options.failDMCommands);
|
||||||
|
}
|
||||||
|
|
||||||
|
return update.process(oauth_);
|
||||||
|
}
|
||||||
|
|
||||||
CocoaTweet::API::Model::Tweet Status::Update(const std::string& _status,
|
CocoaTweet::API::Model::Tweet Status::Update(const std::string& _status,
|
||||||
std::vector<std::string> _mediaId) const {
|
std::vector<std::string> _mediaId) const {
|
||||||
CocoaTweet::API::Statuses::Update update;
|
CocoaTweet::API::Statuses::Update update;
|
||||||
|
|||||||
@@ -5,20 +5,35 @@
|
|||||||
#include "cocoatweet/oauth/oauth.h"
|
#include "cocoatweet/oauth/oauth.h"
|
||||||
#include <cocoatweet/api/model/tweet.h>
|
#include <cocoatweet/api/model/tweet.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <utility>
|
||||||
namespace CocoaTweet::API::Statuses {
|
namespace CocoaTweet::API::Statuses {
|
||||||
class Status : public groupInterface {
|
class Status : public groupInterface {
|
||||||
public:
|
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;
|
||||||
|
};
|
||||||
Status() = default;
|
Status() = default;
|
||||||
Status(std::shared_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
|
Status(std::shared_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
|
||||||
CocoaTweet::API::Model::Tweet Update(const std::string& _status) const;
|
CocoaTweet::API::Model::Tweet Update(const std::string& _status) const;
|
||||||
|
|
||||||
|
CocoaTweet::API::Model::Tweet Update(const std::string& _status, const Options _options) const;
|
||||||
|
|
||||||
CocoaTweet::API::Model::Tweet Update(const std::string& _status,
|
CocoaTweet::API::Model::Tweet Update(const std::string& _status,
|
||||||
std::vector<std::string> _mediaId) const;
|
std::vector<std::string> _mediaId) const;
|
||||||
|
|
||||||
CocoaTweet::API::Model::Tweet Destroy(const std::string& _id) const;
|
CocoaTweet::API::Model::Tweet Destroy(const std::string& _id) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Options defaultOpt_;
|
||||||
};
|
};
|
||||||
} // namespace CocoaTweet::API::Statuses
|
} // namespace CocoaTweet::API::Statuses
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,43 @@ void Update::mediaId(const std::vector<std::string> _media) {
|
|||||||
bodyParam_.insert_or_assign("media_ids", CocoaTweet::Util::join(_media, ","));
|
bodyParam_.insert_or_assign("media_ids", CocoaTweet::Util::join(_media, ","));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Update::replyToStatusId(const std::string _reply){
|
||||||
|
bodyParam_.insert_or_assign("in_reply_to_status_id", _reply);
|
||||||
|
}
|
||||||
|
|
||||||
|
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){
|
||||||
|
bodyParam_.insert_or_assign("exclude_reply_user_ids", CocoaTweet::Util::join(_ex, ","));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update::attachmentUrl(const std::string _url){
|
||||||
|
bodyParam_.insert_or_assign("attachment_url", _url);
|
||||||
|
}
|
||||||
|
|
||||||
|
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){
|
||||||
|
bodyParam_.insert_or_assign("display_coordinates", std::to_string(_disp));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update::trimUser(bool _trim){
|
||||||
|
bodyParam_.insert_or_assign("trim_user", std::to_string(_trim));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update::enableDMCommands(bool _enable){
|
||||||
|
bodyParam_.insert_or_assign("enable_dmcommands", std::to_string(_enable));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update::failDMCommands(bool _fail){
|
||||||
|
bodyParam_.insert_or_assign("fail_dmcommands", std::to_string(_fail));
|
||||||
|
}
|
||||||
|
|
||||||
CocoaTweet::API::Model::Tweet Update::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
|
CocoaTweet::API::Model::Tweet Update::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
|
||||||
CocoaTweet::API::Model::Tweet tweet;
|
CocoaTweet::API::Model::Tweet tweet;
|
||||||
HttpPost::process(_oauth,
|
HttpPost::process(_oauth,
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#ifndef COCOATWEET_API_STATUS_UPDATE_H_
|
#ifndef COCOATWEET_API_STATUS_UPDATE_H_
|
||||||
#define COCOATWEET_API_STATUS_UPDATE_H_
|
#define COCOATWEET_API_STATUS_UPDATE_H_
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <cocoatweet/api/interface/httpPost.h>
|
#include <cocoatweet/api/interface/httpPost.h>
|
||||||
#include <cocoatweet/api/model/tweet.h>
|
#include <cocoatweet/api/model/tweet.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <utility>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace CocoaTweet::API::Statuses {
|
namespace CocoaTweet::API::Statuses {
|
||||||
class Update : public CocoaTweet::API::Interface::HttpPost {
|
class Update : public CocoaTweet::API::Interface::HttpPost {
|
||||||
@@ -14,6 +15,24 @@ public:
|
|||||||
|
|
||||||
void mediaId(const std::vector<std::string> _media);
|
void mediaId(const std::vector<std::string> _media);
|
||||||
|
|
||||||
|
void replyToStatusId(const std::string _reply);
|
||||||
|
|
||||||
|
void autoPopulateReplyMetaData(bool _meta);
|
||||||
|
|
||||||
|
void excludeReplyUserId(const std::vector<std::string> _ex);
|
||||||
|
|
||||||
|
void attachmentUrl(const std::string _url);
|
||||||
|
|
||||||
|
void coord(std::pair<std::string, std::string> _coord);
|
||||||
|
|
||||||
|
void displayCoord(bool _disp);
|
||||||
|
|
||||||
|
void trimUser(bool _trim);
|
||||||
|
|
||||||
|
void enableDMCommands(bool _enable);
|
||||||
|
|
||||||
|
void failDMCommands(bool _fail);
|
||||||
|
|
||||||
CocoaTweet::API::Model::Tweet process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
|
CocoaTweet::API::Model::Tweet process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user