?
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#include "cocoatweet/api/user/show.h"
|
||||
#include <cocoatweet/util/util.h>
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
namespace CocoaTweet::API::Users {
|
||||
Show::Show() {
|
||||
contentType_ = "application/x-www-form-urlencoded";
|
||||
url_ = "https://api.twitter.com/1.1/users/show.json";
|
||||
}
|
||||
|
||||
void Show::screenName(const std::string& _screenName) {
|
||||
if(bodyParam_.count("user_id") > 0){
|
||||
bodyParam_.erase("user_id");
|
||||
}
|
||||
bodyParam_.insert_or_assign("screen_name", _screenName);
|
||||
}
|
||||
|
||||
void Show::id(const std::string& _id) {
|
||||
if(bodyParam_.count("screen_name") > 0){
|
||||
bodyParam_.erase("screen_name");
|
||||
}
|
||||
bodyParam_.insert_or_assign("id", _id);
|
||||
}
|
||||
|
||||
CocoaTweet::API::Model::User Show::process(
|
||||
std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
|
||||
CocoaTweet::API::Model::User user;
|
||||
HttpGet::process(_oauth, [&user](const std::string& _rcv) {
|
||||
user = CocoaTweet::API::Model::User::parse(_rcv);
|
||||
});
|
||||
return user;
|
||||
}
|
||||
|
||||
} // namespace CocoaTweet::API::Statuses
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef COCOATWEET_API_USER_SHOW_H_
|
||||
#define COCOATWEET_API_USER_SHOW_H_
|
||||
|
||||
#include <cocoatweet/api/interface/httpGet.h>
|
||||
#include <cocoatweet/api/model/user.h>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
|
||||
namespace CocoaTweet::API::Users {
|
||||
/// @brief class for using users/show endpoint
|
||||
class Show : public CocoaTweet::API::Interface::HttpGet {
|
||||
public:
|
||||
/// @brief primary constructor
|
||||
Show();
|
||||
|
||||
/// @brief set screen name to get user information
|
||||
/// @param[in] const std::string& _id : screen name for getting information
|
||||
void id(const std::string& _id);
|
||||
|
||||
/// @brief set screen name to get user information
|
||||
/// @param[in] const std::string& _screenName : screen name for getting information
|
||||
void screenName(const std::string& _screenName);
|
||||
|
||||
/// @brief process request for endpoint
|
||||
/// @param[in] std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth : pointer to oauth object
|
||||
/// @param[out] CocoaTweet::API::Model::User : request result
|
||||
CocoaTweet::API::Model::User process(
|
||||
std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
|
||||
|
||||
private:
|
||||
std::string status_;
|
||||
};
|
||||
} // namespace CocoaTweet::API::Statuses
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <cocoatweet/api/user/user.h>
|
||||
#include <cocoatweet/api/user/show.h>
|
||||
|
||||
namespace CocoaTweet::API::Users{
|
||||
User::User(std::shared_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
|
||||
oauth_ = _oauth;
|
||||
}
|
||||
|
||||
CocoaTweet::API::Model::User User::show(const std::string& _screenName)const{
|
||||
CocoaTweet::API::Users::Show show;
|
||||
show.screenName(_screenName);
|
||||
return show.process(oauth_);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef COCOATWEET_API_USER_USER_H_
|
||||
#define COCOATWEET_API_USER_USER_H_
|
||||
|
||||
#include "cocoatweet/api/interface/groupInterface.h"
|
||||
#include "cocoatweet/oauth/oauth.h"
|
||||
#include <cocoatweet/api/model/user.h>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
namespace CocoaTweet::API::Users {
|
||||
/// @brief class for using users/show endpoint
|
||||
class User : public groupInterface {
|
||||
public:
|
||||
/// @brief primary constructor
|
||||
User() = default;
|
||||
|
||||
/// @brief constructor which finally should to be called.
|
||||
/// @param[in] std::shared_ptr<CocoaTweet::OAuth::OAuth1> : pointer to OAuth object
|
||||
User(std::shared_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
|
||||
|
||||
CocoaTweet::API::Model::User show(const std::string& _screenName) const;
|
||||
|
||||
};
|
||||
} // namespace CocoaTweet::API::Statuses
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user