mastodonpp  0.0.0
connection.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_CONNECTION_HPP
18 #define MASTODONPP_CONNECTION_HPP
19 
20 #include "api.hpp"
21 #include "curl_wrapper.hpp"
22 #include "instance.hpp"
23 #include "return_types.hpp"
24 
25 #include <string>
26 #include <string_view>
27 
28 namespace mastodonpp
29 {
30 
31 using std::string;
32 using std::string_view;
33 
41 class Connection : public CURLWrapper
42 {
43 public:
51  explicit Connection(Instance &instance);
52 
61  [[nodiscard]]
62  answer_type get(const API::endpoint_type &endpoint);
63 
71  [[nodiscard]]
72  answer_type get(const string_view &endpoint);
73 
74 private:
75  Instance &_instance;
76  const string_view _baseuri;
77 };
78 
79 } // namespace mastodonpp
80 
81 #endif // MASTODONPP_CONNECTION_HPP
mastodonpp::Connection::Connection
Connection(Instance &instance)
Construct a new Connection object.
Definition: connection.cpp:22
mastodonpp
C++ wrapper for the Mastodon API.
Definition: api.cpp:19
mastodonpp::Connection::get
answer_type get(const API::endpoint_type &endpoint)
Make a HTTP GET call.
Definition: connection.cpp:27
mastodonpp::answer_type
Return type for Requests.
Definition: return_types.hpp:40
mastodonpp::Instance
Holds the access data of an instance.
Definition: instance.hpp:40
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
mastodonpp::Connection
Represents a connection to an instance. Used for requests.
Definition: connection.hpp:41
mastodonpp::CURLWrapper
Handles the details of network connections.
Definition: curl_wrapper.hpp:56