17 #ifndef MASTODONPP_CONNECTION_HPP
18 #define MASTODONPP_CONNECTION_HPP
21 #include "curl_wrapper.hpp"
22 #include "instance.hpp"
26 #include <string_view>
34 using std::string_view;
151 return get(endpoint, {});
188 return post(endpoint, {});
214 return patch(endpoint, {});
240 return put(endpoint, {});
266 return del(endpoint, {});
296 const string_view _baseuri;
304 #endif // MASTODONPP_CONNECTION_HPP
answer_type get(const endpoint_variant &endpoint, const parametermap ¶meters)
Make a HTTP GET call with parameters.
Definition: connection.cpp:34
void copy_connection_properties(CURLWrapper &curlwrapper) const
Set the properties of the connection of the calling class up.
Definition: instance.hpp:90
Connection(const Instance &instance)
Construct a new Connection object.
Definition: connection.hpp:88
string type
The type of the event.
Definition: connection.hpp:62
answer_type post(const endpoint_variant &endpoint)
Make a HTTP POST call.
Definition: connection.hpp:186
map< string_view, variant< string_view, vector< string_view > >> parametermap
std::map of parameters for API calls.
Definition: types.hpp:64
answer_type put(const endpoint_variant &endpoint)
Make a HTTP PUT call.
Definition: connection.hpp:238
string data
The payload.
Definition: connection.hpp:65
string_view get_baseuri() const noexcept
Returns the base URI.
Definition: instance.hpp:115
C++ wrapper for the Mastodon API.
Definition: api.cpp:19
answer_type patch(const endpoint_variant &endpoint)
Make a HTTP PATCH call.
Definition: connection.hpp:212
answer_type put(const endpoint_variant &endpoint, const parametermap ¶meters)
Make a HTTP PUT call with parameters.
Definition: connection.cpp:55
vector< event_type > get_new_events()
Get new stream events.
Definition: connection.cpp:79
~Connection() noexcept override=default
Destructor.
answer_type del(const endpoint_variant &endpoint)
Make a HTTP DELETE call.
Definition: connection.hpp:264
void cancel_stream()
Cancel the stream.
Definition: connection.hpp:290
variant< API::endpoint_type, string_view > endpoint_variant
An endpoint. Either API::endpoint_type or std::string_view.
Definition: connection.hpp:43
answer_type del(const endpoint_variant &endpoint, const parametermap ¶meters)
Make a HTTP DELETE call with parameters.
Definition: connection.cpp:62
A stream event.
Definition: connection.hpp:52
Return type for Requests.
Definition: types.hpp:79
answer_type patch(const endpoint_variant &endpoint, const parametermap ¶meters)
Make a HTTP PATCH call with parameters.
Definition: connection.cpp:48
Holds the access data of an instance.
Definition: instance.hpp:48
answer_type post(const endpoint_variant &endpoint, const parametermap ¶meters)
Make a HTTP POST call with parameters.
Definition: connection.cpp:41
Represents a connection to an instance. Used for requests.
Definition: connection.hpp:78
Handles the details of network connections.
Definition: curl_wrapper.hpp:58
string get_new_stream_contents()
Copy new stream contents and delete the “original”.
Definition: connection.cpp:69
void cancel_stream()
Cancel the stream.
Definition: curl_wrapper.hpp:212