105 lines
2.0 KiB
C++
105 lines
2.0 KiB
C++
|
|
#include "nlohmann/json_fwd.hpp"
|
|
#include <Redmine/User.hpp>
|
|
#include <cstdint>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
#define LOGURU_WITH_STREAMS 1
|
|
#include <loguru.hpp>
|
|
|
|
void Redmine::User::set(const nlohmann::json &data)
|
|
{
|
|
_verify(data);
|
|
data_=data;
|
|
}
|
|
|
|
nlohmann::json Redmine::User::get() const
|
|
{
|
|
return data_;
|
|
}
|
|
|
|
void Redmine::User::_verify(const nlohmann::json &data)
|
|
{
|
|
|
|
_baseVerify(data, "user");
|
|
|
|
nlohmann::json attributes = data["user"];
|
|
|
|
|
|
}
|
|
|
|
Redmine::User::User(const nlohmann::json &user) : Redmine::Object()
|
|
{
|
|
set(user);
|
|
}
|
|
|
|
|
|
std::string Redmine::User::getFullName() const
|
|
{
|
|
return data_["user"]["firstname"].get<std::string>() + " " + data_["user"]["lastname"].get<std::string>();
|
|
}
|
|
|
|
std::string Redmine::User::getFirstName() const
|
|
{
|
|
return data_["user"]["firstname"].get<std::string>();
|
|
}
|
|
|
|
std::string Redmine::User::getLastName() const
|
|
{
|
|
return data_["user"]["lastname"].get<std::string>();
|
|
}
|
|
|
|
std::string Redmine::User::getEmail() const
|
|
{
|
|
return data_["user"]["mail"].get<std::string>();
|
|
}
|
|
|
|
bool Redmine::User::isAdmin() const
|
|
{
|
|
return data_["user"]["admin"].get<bool>() == true;
|
|
}
|
|
|
|
std::string Redmine::User::getAvatarURL() const
|
|
{
|
|
return data_["user"]["avatar_url"].get<std::string>();
|
|
}
|
|
|
|
std::string Redmine::User::to_string() const
|
|
{
|
|
return data_["user"].dump(2);
|
|
}
|
|
|
|
std::uint32_t Redmine::User::getId() const
|
|
{
|
|
return data_["user"]["id"].get<std::uint32_t>();
|
|
}
|
|
|
|
std::string Redmine::User::getLogin() const
|
|
{
|
|
return data_["user"]["login"].get<std::string>();
|
|
}
|
|
|
|
void Redmine::User::setFirstName(const std::string &firstname)
|
|
{
|
|
data_["user"]["firstname"]=firstname;
|
|
}
|
|
|
|
void Redmine::User::setLastName(const std::string &lastname)
|
|
{
|
|
data_["user"]["lastname"]=lastname;
|
|
}
|
|
|
|
void Redmine::User::setLogin(const std::string &login)
|
|
{
|
|
data_["user"]["login"]=login;
|
|
}
|
|
|
|
void Redmine::User::setId(const std::string &id)
|
|
{
|
|
data_["user"]["id"]=id;
|
|
}
|
|
|
|
void Redmine::User::setMail(const std::string &mail)
|
|
{
|
|
data_["user"]["mail"]=mail;
|
|
} |