summaryrefslogtreecommitdiff
path: root/battleNetApi/src/apiUrl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'battleNetApi/src/apiUrl.cpp')
-rw-r--r--battleNetApi/src/apiUrl.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/battleNetApi/src/apiUrl.cpp b/battleNetApi/src/apiUrl.cpp
index ac8171b..1f11add 100644
--- a/battleNetApi/src/apiUrl.cpp
+++ b/battleNetApi/src/apiUrl.cpp
@@ -1,4 +1,5 @@
#include "apiUrl.hpp"
+#include <cstdint>
#include <format>
ApiUrl::ApiUrl(const std::string &iContentType, const std::string &iRegion)
@@ -12,35 +13,36 @@ void ApiUrl::setLocale(const std::string &iLocale) {
if (not iLocale.empty()) {
//!< The locale to reflect in localized data, e.g. "fr_FR" or "ko_KR"
//!< If you do not supply a value, all translations are returned.
- const std::string kKey{"locale"};
- setValue(kKey, iLocale);
+ setValue(kLOCALE_KEY, iLocale);
}
}
void ApiUrl::setGameMode(const std::string &iGameMode) {
if (not iGameMode.empty()) {
//!< A recognized game mode, e.g. "constructed"
//!< @see https://community.developer.battle.net/documentation/hearthstone/guides/game-modes
- const std::string kKey{"gameMode"};
- setValue(kKey, iGameMode);
+ setValue(kGAME_MODE_KEY, iGameMode);
}
}
void ApiUrl::setPage(const std::string &iPage) {
if (not iPage.empty()) {
//!< The page to retrieve, e.g. "9"
- const std::string kKey{"page"};
- setValue(kKey, iPage);
+ setValue(kPAGE_KEY, iPage);
}
}
+void ApiUrl::setPage(uint64_t iPage) { setPage(std::to_string(iPage)); }
void ApiUrl::setPageSize(const std::string &iPageSize) {
if (not iPageSize.empty()) {
//!< The number of results to choose per page, e.g. "40"
- const std::string kKey{"pageSize"};
- setValue(kKey, iPageSize);
+ setValue(kPAGE_SIZE_KEY, iPageSize);
}
}
-
+void ApiUrl::setPageSize(uint64_t iPageSize) { return setPageSize(std::to_string(iPageSize)); }
+bool ApiUrl::hasLocale() const { return hasValue(kLOCALE_KEY); }
+bool ApiUrl::hasGameMode() const { return hasValue(kGAME_MODE_KEY); }
+bool ApiUrl::hasPage() const { return hasValue(kPAGE_KEY); }
+bool ApiUrl::hasPageSize() const { return hasValue(kPAGE_SIZE_KEY); }
void ApiUrl::setValue(const std::string &iKey, const std::string &iValue) { aParameters[iKey] = iValue; }
-
+bool ApiUrl::hasValue(const std::string &iKey) const { return aParameters.count(iKey) > 0; }
std::string ApiUrl::text() const {
std::string aFormattedParameters;
for (const auto &[key, value] : aParameters) {