mastodon-cpp  0.18.8
account.hpp
1 /* This file is part of mastodon-cpp.
2  * Copyright © 2018 tastytea <tastytea@tastytea.de>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef MASTODON_CPP_EASY_ACCOUNT_HPP
18 #define MASTODON_CPP_EASY_ACCOUNT_HPP
19 
20 #include <string>
21 #include <cstdint>
22 #include <chrono>
23 #include <vector>
24 #include <utility>
25 
26 // If we are compiling mastodon-cpp, use another include path
27 #ifdef MASTODON_CPP
28  #include "mastodon-cpp.hpp"
29  #include "easy/easy.hpp"
30 #else
31  #include <mastodon-cpp/mastodon-cpp.hpp>
32  #include <mastodon-cpp/easy/easy.hpp>
33 #endif
34 
35 using std::string;
36 using std::uint_fast64_t;
37 using std::chrono::system_clock;
38 
39 namespace Mastodon
40 {
46  class Easy::Account : public Easy::Entity
47  {
48  public:
54  using fields_pair = std::pair<const string, const string>;
55 
63  explicit Account(const string &json);
64 
70  Account();
71 
72  virtual const bool valid() const;
73 
82  const string acct() const;
83 
89  const string avatar() const;
90 
98  Account avatar(const string &avatar);
99 
105  const string avatar_static() const;
106 
112  const bool bot() const;
113 
119  const system_clock::time_point created_at() const;
120 
126  const string display_name() const;
127 
133  Account display_name(const string &display_name);
134 
140  const std::vector<fields_pair> fields() const;
141 
147  Account fields(std::vector<fields_pair> &fields);
148 
154  const uint_fast64_t followers_count() const;
155 
161  const uint_fast64_t following_count() const;
162 
168  const string header() const;
169 
177  Account header(const string &header);
178 
184  const string header_static() const;
185 
191  const uint_fast64_t id() const;
192 
198  const bool locked() const;
199 
205  Account locked(const bool &locked);
206 
212  const bool has_moved() const;
213 
220  const Account moved() const;
221 
227  const string note() const;
228 
234  Account note(const string &note);
235 
241  [[deprecated("Will vanish in 1.0.0. Use source() instead.")]]
242  const string note_plain() const;
243 
249  const visibility_type privacy() const;
250 
256  const bool sensitive() const;
257 
263  class Source : public Easy::Entity
264  {
265  public:
273  explicit Source(const string &json);
274 
280  Source();
281 
282  virtual const bool valid() const;
283 
289  const std::vector<fields_pair> fields() const;
290 
296  Source fields(std::vector<fields_pair> &fields);
297 
303  const string note() const;
304 
310  Source note(const string &note);
311 
317  const visibility_type privacy() const;
318 
325 
331  const bool sensitive() const;
332 
338  Source sensitive(const bool &sensitive);
339  };
340 
341  const Source source() const;
342  Account source(const Source &source);
343 
349  const uint_fast64_t statuses_count() const;
350 
356  const string url() const;
357 
363  const string username() const;
364 };
365 }
366 
367 #endif // MASTODON_CPP_EASY_ACCOUNT_HPP
const string avatar() const
Returns URL of avatar.
Definition: account.cpp:61
const uint_fast64_t statuses_count() const
Returns number of statuses.
Definition: account.cpp:362
const std::vector< fields_pair > fields() const
Returns metadata fields.
Definition: account.cpp:98
const string header() const
Returns URL of header image.
Definition: account.cpp:141
const system_clock::time_point created_at() const
Returns time of creation.
Definition: account.cpp:82
const string avatar_static() const
Returns URL of static avatar.
Definition: account.cpp:72
const visibility_type privacy() const
Returns default privacy of new toots.
Definition: account.cpp:210
const string note_plain() const
Returns plaintext version of note.
Definition: account.cpp:205
const std::vector< fields_pair > fields() const
Returns metadata fields.
Definition: account.cpp:244
const string acct() const
Returns username.
Definition: account.cpp:56
const bool has_moved() const
Returns true if the account has been moved.
Definition: account.cpp:173
std::pair< const string, const string > fields_pair
Describes a field. Format: name, value.
Definition: account.hpp:54
const uint_fast64_t followers_count() const
Returns number of followers.
Definition: account.cpp:131
const string note() const
Returns note.
Definition: account.cpp:194
const string note() const
Returns note in plain text.
Definition: account.cpp:278
Source()
Constructs an empty Account::Source object.
Definition: account.cpp:235
const visibility_type privacy() const
Returns default privacy of new toots.
Definition: account.cpp:289
const string header_static() const
Returns URL of static header image.
Definition: account.cpp:152
virtual const bool valid() const
Returns true if the Entity holds valid data.
Definition: account.cpp:239
visibility_type
Describes visibility of toots.
Definition: easy.hpp:68
const uint_fast64_t id() const
Returns account-ID.
Definition: account.cpp:157
const string username() const
Returns username (without )
Definition: account.cpp:372
const bool locked() const
Returns true if the account is locked.
Definition: account.cpp:162
virtual const bool valid() const
Returns true if the Entity holds valid data.
Definition: account.cpp:32
const string display_name() const
Returns display name.
Definition: account.cpp:87
Class to hold accounts.
Definition: account.hpp:46
const Account moved() const
If the owner decided to switch accounts, new account is in this attribute.
Definition: account.cpp:183
const bool sensitive() const
Returns if media is marked as sensitive by default.
Definition: account.cpp:340
const bool sensitive() const
Returns if media is marked as sensitive by default.
Definition: account.cpp:226
Definition: mastodon-cpp.hpp:52
Base class for all entities.
Definition: easy.hpp:304
Class to hold source attribute.
Definition: account.hpp:263
const uint_fast64_t following_count() const
Returns number of people this account follows.
Definition: account.cpp:136
Account()
Constructs an empty Account object.
Definition: account.cpp:28
const bool bot() const
Returns true if the account performs automated actions.
Definition: account.cpp:77
const string url() const
Returns URL of the profile.
Definition: account.cpp:367