summaryrefslogtreecommitdiff
path: root/subprojects/battleNetApi/include/token.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/battleNetApi/include/token.hpp')
-rw-r--r--subprojects/battleNetApi/include/token.hpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/subprojects/battleNetApi/include/token.hpp b/subprojects/battleNetApi/include/token.hpp
new file mode 100644
index 0000000..9c1eb18
--- /dev/null
+++ b/subprojects/battleNetApi/include/token.hpp
@@ -0,0 +1,21 @@
+#include <chrono>
+#include <string>
+
+class Token {
+ public:
+ Token(const std::string &iTokenFilePath);
+ std::string getValidToken() const;
+
+ private:
+ std::string mFilePath; //!< Path to the token file
+
+ void refreshToken() const;
+ void writeNewTokenToFile() const;
+ void writeTokenToFile(const std::string &iToken) const;
+ std::string getValidTokenWithApi() const;
+ std::chrono::seconds getCurrentTime() const;
+ std::string extractFirstMatchRegex(const std::string &t_str, const std::string &t_regex) const;
+ static size_t curlCallbackStringOutput(void *t_contents, size_t t_size, size_t t_nmemb, std::string *t_s);
+
+ friend class TokenTests;
+};