17 #ifndef MASTODONPP_INSTANCE_HPP
18 #define MASTODONPP_INSTANCE_HPP
20 #include "curl_wrapper.hpp"
25 #include <string_view>
33 using std::string_view;
59 explicit Instance(string_view hostname, string_view access_token);
92 curlwrapper.setup_connection_properties(_proxy, _access_token, _cainfo,
125 return _access_token;
138 _access_token = access_token;
214 _useragent = useragent;
257 : _instance{instance}
284 string_view website);
305 const string _baseuri;
308 string _client_secret;
312 const string _hostname;
313 const string _baseuri;
314 string _access_token;
317 vector<string> _post_formats;
Handles the details of network connections.
Definition: curl_wrapper.hpp:58
virtual void set_proxy(string_view proxy)
Set the proxy to use.
Definition: curl_wrapper.cpp:229
void set_access_token(string_view access_token)
Set OAuth 2.0 Bearer Access Token.
Definition: curl_wrapper.cpp:240
virtual void set_useragent(string_view useragent)
Sets the User-Agent.
Definition: curl_wrapper.cpp:276
virtual void set_cainfo(string_view path)
Set path to Certificate Authority (CA) bundle.
Definition: curl_wrapper.cpp:266
Simplifies obtaining an OAuth 2.0 Bearer Access Token.
Definition: instance.hpp:249
answer_type step_1(string_view client_name, string_view scopes, string_view website)
Creates an application via /api/v1/apps.
ObtainToken(Instance &instance)
Constructor.
Definition: instance.hpp:256
answer_type step_2(string_view code)
Creates a token via /oauth/token.
Holds the access data of an instance.
Definition: instance.hpp:49
void set_cainfo(string_view path) override
Set path to Certificate Authority (CA) bundle.
Definition: instance.hpp:198
Instance(const Instance &other)
Copy constructor. A new CURLWrapper is constructed.
Instance(string_view hostname, string_view access_token)
Construct a new Instance object.
void set_access_token(const string_view access_token)
Set OAuth 2.0 Bearer Access Token.
Definition: instance.hpp:136
uint64_t get_max_chars() noexcept
Returns the maximum number of characters per post.
void set_useragent(const string_view useragent) override
Sets the User-Agent.
Definition: instance.hpp:212
string_view get_access_token() const noexcept
Returns the access token.
Definition: instance.hpp:123
answer_type get_nodeinfo()
Returns the NodeInfo of the instance.
Instance(Instance &&other) noexcept=delete
Move constructor.
vector< string > get_post_formats() noexcept
Returns the allowed mime types for statuses.
string_view get_baseuri() const noexcept
Returns the base URI.
Definition: instance.hpp:113
string_view get_hostname() const noexcept
Returns the hostname.
Definition: instance.hpp:101
void copy_connection_properties(CURLWrapper &curlwrapper) const
Set the properties of the connection of the calling class up.
Definition: instance.hpp:90
void set_proxy(const string_view proxy) override
Set the proxy to use.
Definition: instance.hpp:160
~Instance() noexcept override=default
Destructor.
C++ wrapper for the Mastodon API.
Definition: api.hpp:25
Return type for Requests.
Definition: types.hpp:80