mastodon-cpp  0.104.0
account.hpp
1 /* This file is part of mastodon-cpp.
2  * Copyright © 2018, 2019 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 <vector>
23 #include <utility>
24 
25 // If we are compiling mastodon-cpp, use another include path
26 #ifdef MASTODON_CPP
27  #include "mastodon-cpp.hpp"
28  #include "easy/entity.hpp"
29 #else
30  #include <mastodon-cpp/mastodon-cpp.hpp>
31  #include <mastodon-cpp/easy/entity.hpp>
32 #endif
33 
34 using std::string;
35 using std::uint64_t;
36 
37 namespace Mastodon
38 {
39 namespace Easy
40 {
46  class Account : public Entity
47  {
48  public:
49  using Entity::Entity;
50 
56  using fields_pair = std::pair<const string, const string>;
57 
58  virtual bool valid() const override;
59 
68  const string acct() const;
69 
75  const string avatar() const;
76 
84  Account avatar(const string &avatar);
85 
91  const string avatar_static() const;
92 
98  bool bot() const;
99 
105  const Easy::time created_at() const;
106 
112  const string display_name() const;
113 
119  Account display_name(const string &display_name);
120 
126  const std::vector<fields_pair> fields() const;
127 
133  Account fields(std::vector<fields_pair> &fields);
134 
140  uint64_t followers_count() const;
141 
147  uint64_t following_count() const;
148 
154  const string header() const;
155 
163  Account header(const string &header);
164 
170  const string header_static() const;
171 
177  const string id() const;
178 
184  bool locked() const;
185 
191  Account locked(const bool &locked);
192 
198  bool has_moved() const;
199 
206  const Account moved() const;
207 
213  const string note() const;
214 
220  Account note(const string &note);
221 
227  visibility_type privacy() const;
228 
234  bool sensitive() const;
235 
241  class Source : public Entity
242  {
243  public:
244  using Entity::Entity;
245 
246  virtual bool valid() const override;
247 
253  const std::vector<fields_pair> fields() const;
254 
260  Source fields(std::vector<fields_pair> &fields);
261 
267  const string note() const;
268 
274  Source note(const string &note);
275 
281  visibility_type privacy() const;
282 
289 
295  bool sensitive() const;
296 
302  Source sensitive(const bool &sensitive);
303  };
304 
310  const Source source() const;
311 
317  Account source(const Source &source);
318 
324  uint64_t statuses_count() const;
325 
331  const string url() const;
332 
338  const string username() const;
339 };
340 }
341 }
342 
343 #endif // MASTODON_CPP_EASY_ACCOUNT_HPP
const string avatar() const
Returns URL of avatar.
Definition: account.cpp:55
const Source source() const
Get source.
Definition: account.cpp:336
const std::vector< fields_pair > fields() const
Returns metadata fields.
Definition: account.cpp:92
const string header() const
Returns URL of header image.
Definition: account.cpp:137
bool sensitive() const
Returns if media is marked as sensitive by default.
Definition: account.cpp:217
const string avatar_static() const
Returns URL of static avatar.
Definition: account.cpp:66
const std::vector< fields_pair > fields() const
Returns metadata fields.
Definition: account.cpp:227
Entity()
Constructs an empty Entity object.
Definition: entity.cpp:42
const string acct() const
Returns username.
Definition: account.cpp:50
uint64_t following_count() const
Returns number of people this account follows.
Definition: account.cpp:132
virtual bool valid() const override
Returns true if the Entity holds valid data.
Definition: account.cpp:222
uint64_t statuses_count() const
Returns number of statuses.
Definition: account.cpp:347
std::pair< const string, const string > fields_pair
Describes a field. Format: name, value.
Definition: account.hpp:56
bool bot() const
Returns true if the account performs automated actions.
Definition: account.cpp:71
const string note() const
Returns note.
Definition: account.cpp:190
const string note() const
Returns note in plain text.
Definition: account.cpp:263
uint64_t followers_count() const
Returns number of followers.
Definition: account.cpp:127
const string header_static() const
Returns URL of static header image.
Definition: account.cpp:148
visibility_type privacy() const
Returns default privacy of new toots.
Definition: account.cpp:201
virtual bool valid() const override
Returns true if the Entity holds valid data.
Definition: account.cpp:25
const string username() const
Returns username (without @hostname)
Definition: account.cpp:357
const string display_name() const
Returns display name.
Definition: account.cpp:81
Class to hold accounts.
Definition: account.hpp:46
const Easy::time created_at() const
Returns time of creation.
Definition: account.cpp:76
const Account moved() const
If the owner decided to switch accounts, new account is in this attribute.
Definition: account.cpp:179
Collection of things to interface with server software that implements the Mastodon API...
Definition: mastodon-cpp.hpp:52
Base class for all entities.
Definition: entity.hpp:41
visibility_type privacy() const
Returns default privacy of new toots.
Definition: account.cpp:274
bool locked() const
Returns true if the account is locked.
Definition: account.cpp:158
const string id() const
Returns account-ID.
Definition: account.cpp:153
Class to hold source attribute.
Definition: account.hpp:241
Type for time. Converts to time_point and string.
Definition: types_easy.hpp:155
bool sensitive() const
Returns if media is marked as sensitive by default.
Definition: account.cpp:325
visibility_type
Describes visibility of posts.
Definition: types_easy.hpp:53
const string url() const
Returns URL of the profile.
Definition: account.cpp:352
bool has_moved() const
Returns true if the account has been moved.
Definition: account.cpp:169