diff --git a/src/cocoatweet/api/status/userTimeline.cc b/src/cocoatweet/api/status/userTimeline.cc new file mode 100644 index 0000000..7679ce9 --- /dev/null +++ b/src/cocoatweet/api/status/userTimeline.cc @@ -0,0 +1,29 @@ +#include "cocoatweet/api/status/userTimeline.h" +#include +#include "nlohmann/json.hpp" +#include + +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 UserTimeline::process( + std::weak_ptr _oauth) { + std::vector tweet; + HttpGet::process(_oauth, [&tweet](const unsigned int _responseCode, const std::string& _rsv) { + auto json = nlohmann::json::parse(_rsv); + for (auto j : json) { + tweet.push_back(CocoaTweet::API::Model::Tweet::parse(_responseCode, j.dump())); + std::cout << j.dump() << std::endl; + } + }); + return tweet; +} + +} // namespace CocoaTweet::API::Statuses diff --git a/src/cocoatweet/api/status/userTimeline.h b/src/cocoatweet/api/status/userTimeline.h new file mode 100644 index 0000000..eca49fe --- /dev/null +++ b/src/cocoatweet/api/status/userTimeline.h @@ -0,0 +1,30 @@ +#ifndef COCOATWEET_API_STATUS_USERTIMELINE_H_ +#define COCOATWEET_API_STATUS_USERTIMELINE_H_ + +#include +#include +#include +#include +#include + +namespace CocoaTweet::API::Statuses { +/// @brief class for using statuses/update endpoint +class UserTimeline : public CocoaTweet::API::Interface::HttpGet { +public: + /// @brief primary constructor + UserTimeline(); + + void screenName(const std::string& _screenName); + + /// @brief process request for endpoint + /// @param[in] std::weak_ptr _oauth : pointer to oauth object + /// @param[out] CocoaTweet::API::Model::Tweet : request result + std::vector process( + std::weak_ptr _oauth); + +private: + std::string status_; +}; +} // namespace CocoaTweet::API::Statuses + +#endif