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.cpp34
1 files changed, 12 insertions, 22 deletions
diff --git a/battleNetApi/src/apiUrl.cpp b/battleNetApi/src/apiUrl.cpp
index 5ef109c..8775943 100644
--- a/battleNetApi/src/apiUrl.cpp
+++ b/battleNetApi/src/apiUrl.cpp
@@ -3,41 +3,31 @@
#include <format>
namespace bnet {
-namespace {
-std::string gamemodeToString(const GameMode &iGameMode) {
- switch (iGameMode) {
- case GameMode::constructed:
- return "constructed";
- case GameMode::battlegrounds:
- return "battlegrounds";
- case GameMode::mercenaries:
- return "mercenaries";
- }
-}
-}; // namespace
ApiUrl::ApiUrl(const std::string &iContentType, const std::string &iRegion)
: mContentType{iContentType}, mRegion{iRegion} {}
void ApiUrl::setRegion(const std::string &iRegion) {
- if (not iRegion.empty()) {
+ if (!iRegion.empty()) {
mRegion = iRegion; //!< The region of the data to receive, e.g. "eu"
}
}
void ApiUrl::setLocale(const std::string &iLocale) {
- if (not iLocale.empty()) {
+ if (!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.
+ //!< If you do !supply a value, all translations are returned.
setValue(kLOCALE_KEY, iLocale);
}
}
-void ApiUrl::setGameMode(const GameMode &iGameMode) {
- //!< A recognized game mode, e.g. "constructed"
- //!< @see
- //!< https://community.developer.battle.net/documentation/hearthstone/guides/game-modes
- setValue(kGAME_MODE_KEY, gamemodeToString(iGameMode));
+void ApiUrl::setGameMode(const std::string &iGameMode) {
+ if (!iGameMode.empty()) {
+ //!< A recognized game mode, e.g. "constructed"
+ //!< @see
+ //!< https://community.developer.battle.net/documentation/hearthstone/guides/game-modes
+ setValue(kGAME_MODE_KEY, iGameMode);
+ }
}
void ApiUrl::setPage(const std::string &iPage) {
- if (not iPage.empty()) {
+ if (!iPage.empty()) {
//!< The page to retrieve, e.g. "9"
setValue(kPAGE_KEY, iPage);
}
@@ -59,7 +49,7 @@ std::string ApiUrl::text() const {
for (const auto &[key, value] : aParameters) {
aFormattedParameters += std::format("&{}={}", key, value);
}
- if (not aFormattedParameters.empty()) {
+ if (!aFormattedParameters.empty()) {
aFormattedParameters[0] = '?';
}
aFormattedParameters = std::format("https://{}.api.blizzard.com/hearthstone/{}/{}", mRegion,