summaryrefslogtreecommitdiff
path: root/battleNetApi/include/hearthstoneTokenBuilder.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'battleNetApi/include/hearthstoneTokenBuilder.hpp')
-rw-r--r--battleNetApi/include/hearthstoneTokenBuilder.hpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/battleNetApi/include/hearthstoneTokenBuilder.hpp b/battleNetApi/include/hearthstoneTokenBuilder.hpp
index e946fe8..571554f 100644
--- a/battleNetApi/include/hearthstoneTokenBuilder.hpp
+++ b/battleNetApi/include/hearthstoneTokenBuilder.hpp
@@ -6,29 +6,32 @@
#include <tokenBuilder.hpp>
#include <vector>
+namespace bnet {
using nlohmann::json;
static constexpr std::uint64_t kTOKEN_CONTENT_MIN_LENGTH{10};
class HearthstoneTokenBuilder : TokenBuilder {
private:
- std::shared_ptr<Token> mCurrentToken;
- bool mUpdateSourceFile{false};
+ std::shared_ptr<Token> _currentToken;
+ bool _allowBattleNetApiCall{false};
+ bool _allowUpdateSourceFile{false};
+ bool _allowExpiredToken{false};
std::vector<std::string> _credentialJsonPaths;
[[nodiscard]]
bool isUpdateSourceFileAllowed() const;
[[nodiscard]]
- const bool hasExpired(json iTokenJson) const;
+ bool isTokenValid(const json &iTokenJson) const;
static size_t curlCallbackStringOutput(void *iPtr, size_t iSize, size_t iNmemb,
std::string *iUserData);
[[nodiscard]]
std::chrono::seconds getCurrentTime() const;
[[nodiscard]]
- std::pair<std::string, std::uint64_t>
- getTokenWithApi(const std::string &iAgentJsonFilePath) const;
+ Token getTokenWithApi(const std::string &iCredentialsJsonFilePath) const;
[[nodiscard]]
- std::string getTokenFromLocalFile() const;
- void writeTokenToLocalFile(const std::pair<std::string, std::uint64_t> &iToken) const;
+ Token getTokenWithApi(const json &iCredentials) const;
+ void writeTokenToLocalFile(std::shared_ptr<Token> &iToken,
+ const std::string &iTokenFileOutputPath) const;
public:
HearthstoneTokenBuilder(const std::span<std::string> &iJsonPaths);
@@ -40,7 +43,9 @@ class HearthstoneTokenBuilder : TokenBuilder {
HearthstoneTokenBuilder &addCredentialJsonFiles(CredentialJsonPaths... iCredentialJsonPaths) {
(_credentialJsonPaths.push_back(iCredentialJsonPaths), ...);
}
+ HearthstoneTokenBuilder &allowBattleNetApiCall();
HearthstoneTokenBuilder &allowUpdateSourceFile();
+ HearthstoneTokenBuilder &allowExpiredToken();
/**
* @return Create an access token to perform API requests.
* First, the cache files are checked. (Which ones?)
@@ -51,3 +56,4 @@ class HearthstoneTokenBuilder : TokenBuilder {
[[nodiscard]]
std::shared_ptr<Token> getToken() override;
};
+} // namespace bnet