summaryrefslogtreecommitdiff
path: root/subprojects/battleNetApi/include/token.hpp
blob: 9c1eb18a0ec2ac57b37d9d1ed1d09ba66cf7e841 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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;
};