#pragma once
/*
* Copyright (C) 2024 Dominik Meyer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "nlohmann/json_fwd.hpp"
#include
#include
#include
#include
/**
* @brief The main namespace of this library for Redmine related datatypes, classes, and functions
*
*/
namespace Redmine
{
/**
* @brief This class represents a user within the redmine server.
*
*/
class User : public Redmine::Object
{
private:
/// the objects data store
nlohmann::json data_;
/**
* @brief verify user data
*
* @param data - the json object containing the user data
*/
void _verify(const nlohmann::json &data);
public:
/**
* @brief Constructor creating a UserInfo object from json data
*
* @param userinfo
*/
explicit User(const nlohmann::json &user);
/**
* @brief set the user object from a json object
*
* @param data
*/
void set(const nlohmann::json &data);
/**
* @brief return a json object from the user object
*
* @return nlohmann::json
*/
nlohmann::json get() const;
/**
* @brief Get the Full Name of the user
*
* @return std::string
*/
std::string getFullName() const;
/**
* @brief Get the First Name of the user
*
* @return std::string
*/
std::string getFirstName() const;
/**
* @brief Get the Last Name of the user
*
* @return std::string
*/
std::string getLastName() const;
/**
* @brief Get the Email address of the user
*
* @return std::string
*/
std::string getEmail() const;
/**
* @brief check if the user is an admin
*
* @return true
* @return false
*/
bool isAdmin() const;
/**
* @brief Get the url of the avatar image of the user
*
* @return std::string
*/
std::string getAvatarURL() const;
/**
* @brief convert the user object to a string
*
* @return std::string
*/
std::string to_string() const;
/**
* @brief return the user id
*
* @return std::uint32_t
*/
std::uint32_t getId() const;
/**
* @brief Get the login/account of the user
*
* @return std::string
*/
std::string getLogin() const;
/**
* @brief Set the First Name of the user object
*
* *Remember:* you are only updating the local object!
*
* To change something on the server to have to call the appropriate API method.
*
* @param firstname - the new firstname of the user
*/
void setFirstName(const std::string &firstname);
/**
* @brief Set the Last Name of the user object
*
* *Remember:* you are only updating the local object!
*
* To change something on the server to have to call the appropriate API method.
*
* @param lastname - the new lastname of the user
*/
void setLastName(const std::string &lastname);
/**
* @brief Set the login of the user object
*
* *Remember:* you are only updating the local object!
*
* To change something on the server to have to call the appropriate API method.
*
* @param login - the new login of the user
*/
void setLogin(const std::string &login);
/**
* @brief Set the id of the user object
*
* *Remember:* you are only updating the local object!
*
* To change something on the server to have to call the appropriate API method.
*
* @param id - the new id of the user
*/
void setId(const std::string &id);
/**
* @brief Set the email of the user object
*
* *Remember:* you are only updating the local object!
*
* To change something on the server to have to call the appropriate API method.
*
* @param email - the new email of the user
*/
void setMail(const std::string &mail);
}; // class User
}; // namespace Redmine