Holds the access data of an instance.
More...
#include <mastodonpp/instance.hpp>
Holds the access data of an instance.
- Since
- 0.1.0
◆ Instance()
mastodonpp::Instance::Instance |
( |
string |
hostname, |
|
|
string |
access_token |
|
) |
| |
|
explicit |
Construct a new Instance object.
Also queries /api/v1/instance
for ‘max_toot_chars’.
- Parameters
-
hostname | The hostname of the instance. |
access_token | Your access token. |
- Since
- 0.1.0
29 : _hostname{move(hostname)}
30 , _baseuri{
"https://" + _hostname}
31 , _access_token{move(access_token)}
37 _baseuri +
"/api/v1/instance")};
40 debuglog <<
"Querying instance for max_toot_chars…\n";
41 auto &body{answer.body};
42 size_t pos_start{body.find(
"max_toot_chars")};
43 if (pos_start == string::npos)
45 debuglog <<
"max_toot_chars not found.";
48 pos_start = body.find(
':', pos_start) + 1;
49 const size_t pos_end{body.find(
',', pos_start)};
51 const auto max_toot_chars{body.substr(pos_start,
52 pos_end - pos_start)};
53 _max_chars = std::stoull(max_toot_chars);
54 debuglog <<
"Set _max_chars to: " << _max_chars <<
'\n';
57 catch (
const std::exception &e)
59 debuglog <<
"Unexpected exception: " << e.what() <<
'\n';
◆ get_access_token()
string_view mastodonpp::Instance::get_access_token |
( |
| ) |
const |
|
inline |
Returns the access token.
- Since
- 0.1.0
◆ get_baseuri()
string_view mastodonpp::Instance::get_baseuri |
( |
| ) |
const |
|
inline |
Returns the base URI.
The base URI is “https://” + the hostname.
- Since
- 0.1.0
◆ get_hostname()
string_view mastodonpp::Instance::get_hostname |
( |
| ) |
const |
|
inline |
Returns the hostname.
- Since
- 0.1.0
◆ get_max_chars()
uint64_t mastodonpp::Instance::get_max_chars |
( |
| ) |
const |
|
inline |
Returns the maximum number of characters per post.
- Since
- 0.1.0
The documentation for this class was generated from the following files: