summaryrefslogtreecommitdiff
path: root/battleNetApi/include
diff options
context:
space:
mode:
Diffstat (limited to 'battleNetApi/include')
-rw-r--r--battleNetApi/include/token.hpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/battleNetApi/include/token.hpp b/battleNetApi/include/token.hpp
index 34c6d3e..1941ce5 100644
--- a/battleNetApi/include/token.hpp
+++ b/battleNetApi/include/token.hpp
@@ -5,6 +5,8 @@ class Token {
public:
Token(const std::string &iTokenFilePath);
std::string text() const;
+ const bool hasTokenExpired() const;
+ void updateToken();
private:
const std::string mFilePath; //!< Path to the token file
@@ -13,16 +15,17 @@ class Token {
std::string mToken; //!< Token value
/**
- * @return A token that a user can use to perform API requests.
- * A new token might be computed if the current token lifetime expired.
+ * @return An access token that a user can use to perform API requests.
+ * First, the cache file is checked.
+ * A new token is computed if the current token lifetime expired,
+ * or if there is no token at all.
*/
std::string generateToken();
- const bool hasTokenExpired() const;
- void writeNewTokenToLocalFile(const std::string &iTokenContent) const;
+ void writeNewTokenToLocalFile(const std::pair<std::string, std::uint64_t> &iToken) const;
std::string getTokenFromLocalFile() const;
- std::string getTokenWithApi() const;
+ std::pair<std::string, std::uint64_t> getTokenWithApi() const;
std::chrono::seconds getCurrentTime() const;
static size_t curlCallbackStringOutput(void *iPtr, size_t iSize, size_t iNmemb, std::string *iUserData);
- friend class TokenTests;
+ static const std::uint16_t kTokenContentMinLength{10};
};