Files
CocoaTweet/src/cocoatweet/api/status/userTimeline.cc
T
2022-04-23 04:55:43 +09:00

28 lines
910 B
C++

#include "cocoatweet/api/status/userTimeline.h"
#include <cocoatweet/util/util.h>
#include "nlohmann/json.hpp"
namespace CocoaTweet::API::Statuses {
UserTimeline::UserTimeline() {
contentType_ = "application/x-www-form-urlencoded";
url_ = "https://api.twitter.com/1.1/statuses/user_timeline.json";
}
void UserTimeline::screenName(const std::string& _screenName) {
bodyParam_.insert_or_assign("screen_name", _screenName);
}
std::vector<CocoaTweet::API::Model::Tweet> UserTimeline::process(
std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth) {
std::vector<CocoaTweet::API::Model::Tweet> tweet;
HttpGet::process(_oauth, [&tweet](const std::string& _rcv) {
auto json = nlohmann::json::parse(_rcv);
for (auto j : json) {
tweet.push_back(CocoaTweet::API::Model::Tweet::parse(j.dump()));
}
});
return tweet;
}
} // namespace CocoaTweet::API::Statuses