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;
90 , _baseuri{instance.get_baseuri()}
149 return get(endpoint, {});
184 return post(endpoint, {});
208 return patch(endpoint, {});
232 return put(endpoint, {});
256 return del(endpoint, {});
287 const string_view _baseuri;
Handles the details of network connections.
Definition: curl_wrapper.hpp:58
void cancel_stream()
Cancel the stream.
Definition: curl_wrapper.hpp:209
Represents a connection to an instance. Used for requests.
Definition: connection.hpp:79
string get_new_stream_contents()
Copy new stream contents and delete the “original”.
Definition: connection.cpp:69
answer_type del(const endpoint_variant &endpoint, const parametermap ¶meters)
Make a HTTP DELETE call with parameters.
Definition: connection.cpp:62
answer_type patch(const endpoint_variant &endpoint, const parametermap ¶meters)
Make a HTTP PATCH call with parameters.
Definition: connection.cpp:48
answer_type del(const endpoint_variant &endpoint)
Make a HTTP DELETE call.
Definition: connection.hpp:254
~Connection() noexcept override=default
Destructor.
answer_type patch(const endpoint_variant &endpoint)
Make a HTTP PATCH call.
Definition: connection.hpp:206
vector< event_type > get_new_events()
Get new stream events.
Definition: connection.cpp:79
void cancel_stream()
Cancel the stream.
Definition: connection.hpp:280
Connection(const Connection &other)=default
Copy constructor. A new CURLWrapper is constructed.
answer_type put(const endpoint_variant &endpoint, const parametermap ¶meters)
Make a HTTP PUT call with parameters.
Definition: connection.cpp:55
answer_type put(const endpoint_variant &endpoint)
Make a HTTP PUT call.
Definition: connection.hpp:230
answer_type post(const endpoint_variant &endpoint, const parametermap ¶meters)
Make a HTTP POST call with parameters.
Definition: connection.cpp:41
answer_type get(const endpoint_variant &endpoint, const parametermap ¶meters)
Make a HTTP GET call with parameters.
Definition: connection.cpp:34
Connection(const Instance &instance)
Construct a new Connection object.
Definition: connection.hpp:88
Connection(Connection &&other) noexcept=delete
Move constructor.
answer_type post(const endpoint_variant &endpoint)
Make a HTTP POST call.
Definition: connection.hpp:182
Holds the access data of an instance.
Definition: instance.hpp:49
void copy_connection_properties(CURLWrapper &curlwrapper) const
Set the properties of the connection of the calling class up.
Definition: instance.hpp:90
C++ wrapper for the Mastodon API.
Definition: api.hpp:25
variant< API::endpoint_type, string_view > endpoint_variant
An endpoint. Either API::endpoint_type or std::string_view.
Definition: connection.hpp:43
map< string_view, variant< string_view, vector< string_view > >> parametermap
std::map of parameters for API calls.
Definition: types.hpp:64
Return type for Requests.
Definition: types.hpp:80
A stream event.
Definition: connection.hpp:53
string type
The type of the event.
Definition: connection.hpp:62
string data
The payload.
Definition: connection.hpp:65