mastodonpp  0.0.0
api.hpp
1 /* This file is part of mastodonpp.
2  * Copyright © 2020 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 Affero 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 Affero General Public License for more details.
12  *
13  * You should have received a copy of the GNU Affero General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef MASTODONPP_API_HPP
18 #define MASTODONPP_API_HPP
19 
20 #include <map>
21 #include <string_view>
22 #include <variant>
23 
24 namespace mastodonpp
25 {
26 
27 using std::map;
28 using std::string_view;
29 using std::variant;
30 
40 class API
41 {
42 public:
50  enum class v1
51  {
52  apps,
53  apps_verify_credentials,
54 
55  accounts,
56  accounts_verify_credentials,
57  accounts_update_credentials,
58  accounts_id,
59  accounts_id_statuses,
60  accounts_id_followers,
61  accounts_id_following,
62  accounts_id_lists,
63  accounts_id_identity_proofs,
64  accounts_id_follow,
65  accounts_id_unfollow,
66  accounts_id_block,
67  accounts_id_unblock,
68  accounts_id_mute,
69  accounts_id_unmute,
70  accounts_id_pin,
71  accounts_id_unpin,
72  accounts_relationships,
73  accounts_search,
74 
75  bookmarks,
76 
77  favourites,
78 
79  mutes,
80 
81  blocks,
82 
83  domain_blocks,
84 
85  filters,
86  filters_id,
87 
88  reports,
89 
90  follow_requests,
91  follow_requests_id_authorize,
92  follow_requests_id_reject,
93 
94  endorsements,
95 
96  featured_tags,
97  featured_tags_id,
98  featured_tags_suggestions,
99 
100  preferences,
101 
102  suggestions,
103  suggestions_account_id,
104 
105  statuses,
106  statuses_id,
107  statuses_id_context,
108  statuses_id_reblogged_by,
109  statuses_id_favourited_by,
110  statuses_id_favourite,
111  statuses_id_unfavourite,
112  statuses_id_reblog,
113  statuses_id_unreblog,
114  statuses_id_bookmark,
115  statuses_id_unbookmark,
116  statuses_id_mute,
117  statuses_id_unmute,
118  statuses_id_pin,
119  statuses_id_unpin,
120 
121  media,
122  media_id,
123 
124  polls_id,
125  polls_id_votes,
126 
127  scheduled_statuses,
128  scheduled_statuses_id,
129 
130  timelines_public,
131  timelines_tag_hashtag,
132  timelines_home,
133  timelines_list_list_id,
134 
135  conversations,
136  conversations_id,
137  conversations_id_read,
138 
139  lists,
140  lists_id,
141  lists_id_accounts,
142 
143  markers,
144 
145  streaming_health,
146  streaming_user,
147  streaming_public,
148  streaming_public_local,
149  streaming_hashtag,
150  streaming_hashtag_local,
151  streaming_list,
152  streaming_direct,
153 
154  notifications,
155  notifications_id,
156  notifications_clear,
157  notifications_id_dismiss,
158 
159  push_subscription,
160 
161  instance,
162  instance_peers,
163  instance_activity,
164 
165  trends,
166 
167  directory,
168 
169  custom_emojis,
170 
171  admin_accounts,
172  admin_accounts_id,
173  admin_accounts_account_id_action,
174  admin_accounts_id_approve,
175  admin_accounts_id_reject,
176  admin_accounts_id_enable,
177  admin_accounts_id_unsilence,
178  admin_accounts_id_unsuspend,
179  admin_reports,
180  admin_reports_id,
181  admin_reports_id_assign_to_self,
182  admin_reports_id_unassign,
183  admin_reports_id_resolve,
184  admin_reports_id_reopen,
185 
186  pleroma_notifications_read,
187 
188  pleroma_accounts_id_subscribe,
189  pleroma_accounts_id_unsubscribe,
190  pleroma_accounts_id_favourites,
191  pleroma_accounts_update_avatar,
192  pleroma_accounts_update_banner,
193  pleroma_accounts_update_background,
194  pleroma_accounts_confirmation_resend,
195 
196  pleroma_mascot,
197 
198  pleroma_conversations_id_statuses,
199  pleroma_conversations_id,
200  };
201 
209  enum class v2
210  {
211  search
212  };
213 
221  enum class oauth
222  {
223  authorize,
224  token,
225  revoke
226  };
227 
237  enum class other
238  {
239  proofs,
240  oembed
241  };
242 
250  enum class pleroma
251  {
252  admin_users,
253  admin_users_follow,
254  admin_users_unfollow,
255  admin_users_nickname,
256  admin_users_tag,
257  admin_users_nickname_permission_group,
258  admin_users_nickname_permission_group_permission_group,
259  admin_users_nickname_activation_status,
260  admin_users_nickname_or_id,
261  admin_users_nickname_or_id_statuses,
262  admin_relay,
263  admin_users_invite_token,
264  admin_users_invites,
265  admin_users_revoke_invite,
266  admin_users_email_invite,
267  admin_users_nickname_password_reset,
268  admin_reports,
269  admin_reports_id,
270  admin_reports_id_respond,
271  admin_statuses_id,
272  admin_config_migrate_to_db,
273  admin_config_migrate_from_db,
274  admin_config,
275 
276  emoji,
277  follow_import,
278  captcha,
279 
280  delete_account,
281  disable_account,
282  account_register,
283 
284  pleroma_notification_settings,
285  pleroma_healthcheck,
286  pleroma_change_email
287  };
288 
295  using endpoint_type = variant<v1,v2,oauth,other,pleroma>;
296 
305  explicit API(const endpoint_type &endpoint);
306 
312  [[nodiscard]]
313  inline string_view to_string_view() const
314  {
315  return _endpoint_map.at(_endpoint).data();
316  }
317 
318 private:
319  const endpoint_type _endpoint;
320  static const map<endpoint_type,string_view> _endpoint_map;
321 };
322 
323 } // namespace mastodonpp
324 
325 #endif // MASTODONPP_API_HPP
mastodonpp::API::v2
v2
An enumeration of all v2 API endpoints.
Definition: api.hpp:209
mastodonpp::API::oauth
oauth
An enumeration of all oauth API endpoints.
Definition: api.hpp:221
mastodonpp::API::to_string_view
string_view to_string_view() const
Convert endpoint_type to std::string_view.
Definition: api.hpp:313
mastodonpp
C++ wrapper for the Mastodon API.
Definition: answer.cpp:19
mastodonpp::API
Holds API endpoints.
Definition: api.hpp:40
mastodonpp::API::pleroma
pleroma
An enumeration of all pleroma API endpoints.
Definition: api.hpp:250
mastodonpp::API::v1
v1
An enumeration of all v1 API endpoints.
Definition: api.hpp:50
mastodonpp::API::other
other
An enumeration of all other API endpoints.
Definition: api.hpp:237
mastodonpp::API::API
API(const endpoint_type &endpoint)
Constructs an API object. You should never need this.
Definition: api.cpp:22
mastodonpp::API::endpoint_type
variant< v1, v2, oauth, other, pleroma > endpoint_type
Type for endpoints. Can be API::v1, API::v2, API::oauth, API::other or API::pleroma.
Definition: api.hpp:295