From 06109ce40a8b8a9eecf359a006e06227200e768b Mon Sep 17 00:00:00 2001 From: Aotrix <9aotrix@protonmail.com> Date: Sun, 4 Jan 2026 17:38:51 +0100 Subject: Refactoring of Token class --- battleNetApi/include/token.hpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'battleNetApi/include') diff --git a/battleNetApi/include/token.hpp b/battleNetApi/include/token.hpp index e2e3088..f529a08 100644 --- a/battleNetApi/include/token.hpp +++ b/battleNetApi/include/token.hpp @@ -10,13 +10,17 @@ class Token { const std::string mFilePath; //!< Path to the token file const std::string mUsername; //!< Username for Battle.net API const std::string mPassword; //!< Password for Battle.net API - const std::string mToken; //!< Token value + std::string mToken; //!< Token value - std::string getValidToken() const; - void refreshToken() const; - void writeNewTokenToFile() const; - void writeTokenToFile(const std::string &iToken) const; - std::string getValidTokenWithApi() const; + /** + * @return A token that a user can use to perform API requests. + * A new token might be computed if the current token lifetime expired. + */ + std::string getValidToken(); + const bool hasTokenExpired() const; + std::string writeNewTokenToLocalFile() const; + std::string getTokenFromLocalFile() const; + std::string getTokenWithApi() const; std::chrono::seconds getCurrentTime() const; std::string extractTokenWithRegex(const std::string &iText, const std::string &iRegex) const; static size_t curlCallbackStringOutput(void *iPtr, size_t iSize, size_t iNmemb, std::string *iUserData); -- cgit v1.2.3