diff options
| author | Aotrix <[email protected]> | 2025-11-01 19:29:44 +0100 |
|---|---|---|
| committer | Aotrix <[email protected]> | 2025-11-01 19:29:44 +0100 |
| commit | 2d67036e6eede970efb0db5f9793de95093599cd (patch) | |
| tree | e9a139d6435cc7eeece182307a72bee24c7f91d4 /subprojects/battleNetApi/include | |
| parent | 3baa8fa322dbc8f2a2183e8ac027387c75eb9180 (diff) | |
refactoring Token class
Diffstat (limited to 'subprojects/battleNetApi/include')
| -rw-r--r-- | subprojects/battleNetApi/include/hearthstoneApi.hpp | 19 | ||||
| -rw-r--r-- | subprojects/battleNetApi/include/token.hpp | 6 |
2 files changed, 6 insertions, 19 deletions
diff --git a/subprojects/battleNetApi/include/hearthstoneApi.hpp b/subprojects/battleNetApi/include/hearthstoneApi.hpp index fcd84c0..88d48ef 100644 --- a/subprojects/battleNetApi/include/hearthstoneApi.hpp +++ b/subprojects/battleNetApi/include/hearthstoneApi.hpp @@ -1,6 +1,5 @@ #pragma once #include "token.hpp" -#include <chrono> #include <string> class HearthstoneApi { @@ -11,27 +10,13 @@ class HearthstoneApi { friend class HearthstoneApiTests; private: - /** - * @brief Get a valid token to call Battle.net API - * @return A valid token - */ - std::string getValidTokenWithApi() const; - static size_t curlCallbackStringOutput(void *t_contents, size_t t_size, size_t t_nmemb, std::string *t_s); - std::chrono::seconds getCurrentTime() const; - std::string extractStringWithRegex(const std::string &t_str, const std::string t_regex) const; - void writeTokenToFile(const std::string &iToken) const; - void writeNewTokenToFile() const; - void refreshToken(); - std::string getValidToken(); std::string generateRequestHeader(); const std::string getUrl(const std::string &t_parameters); const std::string getSetOfCardsUrl(const std::string &t_card_parameters); std::string makeApiRequest(const char *t_url, const char *t_header); std::string makeApiRequest(const std::string &t_url, const std::string &t_header); + static size_t curlCallbackStringOutput(void *t_contents, size_t t_size, size_t t_nmemb, std::string *t_s); - // TODO: add Token object - // Token mToken; - std::string mTokenFilePath; - std::string mToken; + Token mToken; std::string m_header; }; diff --git a/subprojects/battleNetApi/include/token.hpp b/subprojects/battleNetApi/include/token.hpp index 9c1eb18..e135d3f 100644 --- a/subprojects/battleNetApi/include/token.hpp +++ b/subprojects/battleNetApi/include/token.hpp @@ -4,11 +4,13 @@ class Token { public: Token(const std::string &iTokenFilePath); - std::string getValidToken() const; + std::string toString() const; private: - std::string mFilePath; //!< Path to the token file + const std::string mFilePath; //!< Path to the token file + const std::string mToken; //!< Token value + std::string getValidToken() const; void refreshToken() const; void writeNewTokenToFile() const; void writeTokenToFile(const std::string &iToken) const; |
