17 #ifndef MASTODONPP_INSTANCE_HPP
18 #define MASTODONPP_INSTANCE_HPP
20 #include "curl_wrapper.hpp"
25 #include <string_view>
34 using std::string_view;
61 const string_view access_token)
63 , _baseuri{
"https://" + _hostname}
64 , _access_token{access_token}
116 return _access_token;
129 _access_token = move(access_token);
206 _useragent = useragent;
249 : _instance{instance}
272 answer_type
step_1(string_view client_name, string_view scopes,
273 string_view website);
291 answer_type
step_2(string_view code);
295 const string _baseuri;
298 string _client_secret;
302 const string _hostname;
303 const string _baseuri;
304 string _access_token;
307 vector<string> _post_formats;
314 #endif // MASTODONPP_INSTANCE_HPP
Simplifies obtaining an OAuth 2.0 Bearer Access Token.
Definition: instance.hpp:240
answer_type get_nodeinfo()
Returns the NodeInfo of the instance.
string_view get_hostname() const noexcept
Returns the hostname.
Definition: instance.hpp:90
answer_type step_1(string_view client_name, string_view scopes, string_view website)
Creates an application via /api/v1/apps.
string_view get_baseuri() const noexcept
Returns the base URI.
Definition: instance.hpp:103
C++ wrapper for the Mastodon API.
Definition: api.cpp:19
Instance(const string_view hostname, const string_view access_token)
Construct a new Instance object.
Definition: instance.hpp:60
void set_access_token(string access_token)
Set OAuth 2.0 Bearer Access Token.
Definition: instance.hpp:127
answer_type step_2(string_view code)
Creates a token via /oauth/token.
void set_cainfo(string_view path) override
Set path to Certificate Authority (CA) bundle.
Definition: instance.hpp:190
virtual void set_proxy(string_view proxy)
Set the proxy to use.
Definition: curl_wrapper.cpp:216
vector< string > get_post_formats() noexcept
Returns the allowed mime types for statuses.
uint64_t get_max_chars() noexcept
Returns the maximum number of characters per post.
Return type for Requests.
Definition: types.hpp:79
virtual void set_cainfo(string_view path)
Set path to Certificate Authority (CA) bundle.
Definition: curl_wrapper.cpp:253
Holds the access data of an instance.
Definition: instance.hpp:49
void set_useragent(const string_view useragent) override
Sets the User-Agent.
Definition: instance.hpp:204
virtual void set_useragent(string_view useragent)
Sets the User-Agent.
Definition: curl_wrapper.cpp:263
ObtainToken(Instance &instance)
Constructor.
Definition: instance.hpp:248
Handles the details of network connections.
Definition: curl_wrapper.hpp:58
void copy_connection_properties(CURLWrapper &curlwrapper)
Set the properties of the connection of the calling class up.
Definition: instance.hpp:78
string_view get_access_token() const noexcept
Returns the access token.
Definition: instance.hpp:114
void set_proxy(const string_view proxy) override
Set the proxy to use.
Definition: instance.hpp:151
void setup_connection_properties(string_view proxy, string_view access_token, string_view cainfo, string_view useragent)
Set some properties of the connection.
Definition: curl_wrapper.cpp:190