Instance: Add getters for hostname, baseuri and access_token.
This commit is contained in:
parent
f872707036
commit
db315a3a70
|
@ -20,11 +20,13 @@
|
|||
#include "curl_wrapper.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace mastodonpp
|
||||
{
|
||||
|
||||
using std::string;
|
||||
using std::string_view;
|
||||
|
||||
/*!
|
||||
* @brief Holds the access data of an instance.
|
||||
|
@ -39,15 +41,51 @@ public:
|
|||
/*!
|
||||
* @brief Construct a new Instance object.
|
||||
*
|
||||
* @param instance The hostname of the instance.
|
||||
* @param hostname The hostname of the instance.
|
||||
* @param access_token Your access token.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
explicit Instance(string instance, string access_token);
|
||||
explicit Instance(string hostname, string access_token);
|
||||
|
||||
/*!
|
||||
* @brief Returns the hostname.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
[[nodiscard]]
|
||||
inline string_view get_hostname() const
|
||||
{
|
||||
return _hostname;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Returns the base URI.
|
||||
*
|
||||
* The base URI is “https://” + the hostname.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
[[nodiscard]]
|
||||
inline string_view get_baseuri() const
|
||||
{
|
||||
return _baseuri;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Returns the access token.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
[[nodiscard]]
|
||||
inline string_view get_access_token() const
|
||||
{
|
||||
return _access_token;
|
||||
}
|
||||
|
||||
private:
|
||||
const string _instance;
|
||||
const string _hostname;
|
||||
const string _baseuri;
|
||||
string _access_token;
|
||||
};
|
||||
|
||||
|
|
|
@ -23,8 +23,9 @@ namespace mastodonpp
|
|||
|
||||
using std::move;
|
||||
|
||||
Instance::Instance(string instance, string access_token)
|
||||
: _instance{move(instance)}
|
||||
Instance::Instance(string hostname, string access_token)
|
||||
: _hostname{move(hostname)}
|
||||
, _baseuri{"https://" + _hostname}
|
||||
, _access_token{move(access_token)}
|
||||
{}
|
||||
|
||||
|
|
Loading…
Reference in New Issue