This repository has been archived on 2020-05-10. You can view files and clone it, but cannot push or open issues or pull requests.
mastodon-cpp/src/easy/entities/account.hpp

347 lines
8.2 KiB
C++
Raw Normal View History

2018-03-22 00:33:36 +01:00
/* This file is part of mastodon-cpp.
2019-03-20 06:15:43 +01:00
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
*
2018-03-22 00:33:36 +01:00
* 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, version 3.
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef MASTODON_CPP_EASY_ACCOUNT_HPP
#define MASTODON_CPP_EASY_ACCOUNT_HPP
#include <string>
#include <cstdint>
#include <vector>
#include <utility>
2018-03-22 00:33:36 +01:00
// If we are compiling mastodon-cpp, use another include path
#ifdef MASTODON_CPP
#include "mastodon-cpp.hpp"
2019-03-29 14:44:39 +01:00
#include "easy/entity.hpp"
2018-03-22 00:33:36 +01:00
#else
#include <mastodon-cpp/mastodon-cpp.hpp>
2019-03-29 14:44:39 +01:00
#include <mastodon-cpp/easy/entity.hpp>
2018-03-22 00:33:36 +01:00
#endif
using std::string;
using std::uint64_t;
2018-03-22 00:33:36 +01:00
namespace Mastodon
2019-03-29 14:44:39 +01:00
{
namespace Easy
2018-03-22 00:33:36 +01:00
{
/*!
* @brief Class to hold accounts.
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
2019-03-29 14:44:39 +01:00
class Account : public Entity
2018-03-22 00:33:36 +01:00
{
public:
2019-03-11 20:48:54 +01:00
using Entity::Entity;
/*!
* @brief Describes a field. Format: name, value
*
* @since 0.16.1
*/
using fields_pair = std::pair<const string, const string>;
virtual bool valid() const override;
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns username
*
* `username` for users on the same instance, `user@hostname`
* for users on other instances.
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const string acct() const;
/*!
* @brief Returns URL of avatar
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const string avatar() const;
/*!
* @brief Sets avatar
2019-03-29 14:44:39 +01:00
*
* Filename or base64-encoded
2019-03-29 14:44:39 +01:00
*
* @since 0.18.5
*/
Account avatar(const string &avatar);
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns URL of static avatar
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const string avatar_static() const;
/*!
* @brief Returns true if the account performs automated actions
2019-03-29 14:44:39 +01:00
*
* @since 0.16.0
*/
2018-12-04 11:26:28 +01:00
bool bot() const;
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns time of creation
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
2019-03-29 14:44:39 +01:00
const Easy::time created_at() const;
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns display name
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const string display_name() const;
/*!
* @brief Sets display name
2019-03-29 14:44:39 +01:00
*
* @since 0.18.5
*/
Account display_name(const string &display_name);
/*!
* @brief Returns metadata fields
2019-03-29 14:44:39 +01:00
*
* @since 0.16.1
*/
const std::vector<fields_pair> fields() const;
/*!
* @brief Sets metadata fields
2019-03-29 14:44:39 +01:00
*
* @since 0.18.5
*/
Account fields(std::vector<fields_pair> &fields);
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns number of followers
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
uint64_t followers_count() const;
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns number of people this account follows
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
uint64_t following_count() const;
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns URL of header image
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const string header() const;
/*!
* @brief Sets header image
2019-03-29 14:44:39 +01:00
*
* Filename or base64-encoded.
2019-03-29 14:44:39 +01:00
*
* @since 0.18.5
*/
Account header(const string &header);
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns URL of static header image
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const string header_static() const;
/*!
* @brief Returns account-ID
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const string id() const;
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns true if the account is locked
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
2018-12-04 11:26:28 +01:00
bool locked() const;
2018-03-22 00:33:36 +01:00
/*!
* @brief Sets locked state
2019-03-29 14:44:39 +01:00
*
* @since 0.18.5
*/
Account locked(const bool &locked);
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns true if the account has been moved
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
2018-12-04 11:26:28 +01:00
bool has_moved() const;
2018-03-22 00:33:36 +01:00
/*!
* @brief If the owner decided to switch accounts, new account is in
* this attribute
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const Account moved() const;
/*!
* @brief Returns note
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const string note() const;
/*!
* @brief Sets note
2019-03-29 14:44:39 +01:00
*
* @since 0.18.5
*/
Account note(const string &note);
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns default privacy of new toots
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
2018-12-04 11:26:28 +01:00
visibility_type privacy() const;
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns if media is marked as sensitive by default
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
2018-12-04 11:26:28 +01:00
bool sensitive() const;
2018-03-22 00:33:36 +01:00
/*!
* @brief Class to hold source attribute
2019-03-29 14:44:39 +01:00
*
* @since 0.18.5
*/
class Source : public Easy::Entity
{
public:
/*!
* @brief Constructs an Account::Source object from a JSON string.
*
* @param json JSON string
2019-03-29 14:44:39 +01:00
*
* @since 0.18.5
*/
explicit Source(const string &json);
/*!
* @brief Constructs an empty Account::Source object.
2019-03-29 14:44:39 +01:00
*
* @since 0.18.5
*/
Source();
virtual bool valid() const override;
/*!
* @brief Returns metadata fields
2019-03-29 14:44:39 +01:00
*
* @since 0.18.5
*/
const std::vector<fields_pair> fields() const;
/*!
* @brief Sets metadata fields
2019-03-29 14:44:39 +01:00
*
* @since 0.18.5
*/
Source fields(std::vector<fields_pair> &fields);
/*!
* @brief Returns note in plain text
2019-03-29 14:44:39 +01:00
*
* @since 0.18.5
*/
const string note() const;
/*!
* @brief Sets note
2019-03-29 14:44:39 +01:00
*
* @since 0.18.5
*/
Source note(const string &note);
/*!
* @brief Returns default privacy of new toots
2019-03-29 14:44:39 +01:00
*
* @since 0.18.5
*/
2018-12-04 11:26:28 +01:00
visibility_type privacy() const;
/*!
* @brief Sets default privacy of new toots
2019-03-29 14:44:39 +01:00
*
* @since 0.18.5
*/
Source privacy(const visibility_type &privacy);
/*!
* @brief Returns if media is marked as sensitive by default
2019-03-29 14:44:39 +01:00
*
* @since 0.18.5
*/
2018-12-04 11:26:28 +01:00
bool sensitive() const;
/*!
* @brief Sets if media is marked as sensitive by default
2019-03-29 14:44:39 +01:00
*
* @since 0.18.5
*/
Source sensitive(const bool &sensitive);
};
const Source source() const;
Account source(const Source &source);
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns number of statuses
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
uint64_t statuses_count() const;
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns URL of the profile
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const string url() const;
/*!
2019-02-19 04:41:24 +01:00
* @brief Returns username (without \@hostname)
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const string username() const;
};
}
2019-03-29 14:44:39 +01:00
}
2018-03-22 00:33:36 +01:00
#endif // MASTODON_CPP_EASY_ACCOUNT_HPP