From 64c0ffef1043226433574fc945da93bea4e20adb Mon Sep 17 00:00:00 2001 From: Daivuk Date: Mon, 27 Sep 2021 14:55:48 -0400 Subject: [PATCH] BCLOUD-1079 getSelectedProperties/InCategories --- include/braincloud/BrainCloudGlobalApp.h | 26 ++++++++++++++++++++++++ include/braincloud/OperationParam.h | 4 ++++ include/braincloud/ServiceOperation.h | 2 ++ src/BrainCloudGlobalApp.cpp | 23 +++++++++++++++++++++ src/OperationParam.cpp | 3 +++ src/ServiceOperation.cpp | 2 ++ tests/src/TestBCGlobalApp.cpp | 16 +++++++++++++++ 7 files changed, 76 insertions(+) diff --git a/include/braincloud/BrainCloudGlobalApp.h b/include/braincloud/BrainCloudGlobalApp.h index a10ec752..8f4b4ad9 100644 --- a/include/braincloud/BrainCloudGlobalApp.h +++ b/include/braincloud/BrainCloudGlobalApp.h @@ -3,6 +3,8 @@ #pragma once #include +#include +#include namespace BrainCloud { @@ -24,6 +26,30 @@ namespace BrainCloud */ void readProperties(IServerCallback * in_callback = NULL); + /** + * Returns a list of properties, identified by the property names provided. + * If a property from the list isn't found, it just isn't returned (no error). + * + * Service Name - GlobalApp + * Service Operation - READ_SELECTED_PROPERTIES + * + * @param propertyNames Specifies which properties to return + * @param in_callback The method to be invoked when the server response is received + */ + void readSelectedProperties(const std::vector &propertyNames, IServerCallback * in_callback = NULL); + + /** + * Returns a list of properties, identified by the categories provided. + * If a category from the list isn't found, it just isn't returned (no error). + * + * Service Name - GlobalApp + * Service Operation - READ_PROPERTIES_IN_CATEGORIES + * + * @param categories Specifies which category to return + * @param in_callback The method to be invoked when the server response is received + */ + void readPropertiesInCategories(const std::vector &categories, IServerCallback * in_callback = NULL); + private: BrainCloudClient * m_client; }; diff --git a/include/braincloud/OperationParam.h b/include/braincloud/OperationParam.h index 4e76a0b8..f29a2bf4 100644 --- a/include/braincloud/OperationParam.h +++ b/include/braincloud/OperationParam.h @@ -331,6 +331,10 @@ namespace BrainCloud { static const OperationParam DataStreamEventName; static const OperationParam DataStreamEventProperties; + // Global Properties + static const OperationParam GlobalAppPropertyNames; + static const OperationParam GlobalAppCategories; + // Profanity static const OperationParam ProfanityText; static const OperationParam ProfanityReplaceSymbol; diff --git a/include/braincloud/ServiceOperation.h b/include/braincloud/ServiceOperation.h index 0b104203..7848a6cf 100644 --- a/include/braincloud/ServiceOperation.h +++ b/include/braincloud/ServiceOperation.h @@ -290,6 +290,8 @@ namespace BrainCloud { static const ServiceOperation UpdateLanguageCode; static const ServiceOperation ReadProperties; + static const ServiceOperation ReadSelectedProperties; + static const ServiceOperation ReadPropertiesInCategories; static const ServiceOperation GetUpdatedFiles; static const ServiceOperation GetFileList; diff --git a/src/BrainCloudGlobalApp.cpp b/src/BrainCloudGlobalApp.cpp index c5fd8949..c9ac50ab 100644 --- a/src/BrainCloudGlobalApp.cpp +++ b/src/BrainCloudGlobalApp.cpp @@ -10,6 +10,9 @@ #include "braincloud/OperationParam.h" #include "json/json.h" +#include "braincloud/internal/StringUtil.h" +#include "braincloud/internal/JsonUtil.h" + namespace BrainCloud { BrainCloudGlobalApp::BrainCloudGlobalApp(BrainCloudClient* in_client) : m_client(in_client) { } @@ -20,4 +23,24 @@ namespace BrainCloud ServerCall * sc = new ServerCall(ServiceName::GlobalApp, ServiceOperation::ReadProperties, message, in_callback); m_client->sendRequest(sc); } + + void BrainCloudGlobalApp::readSelectedProperties(const std::vector &propertyNames, IServerCallback * in_callback) + { + Json::Value message = Json::nullValue; + + message[OperationParam::GlobalAppPropertyNames.getValue()] = JsonUtil::stringVectorToJson(propertyNames); + + ServerCall * sc = new ServerCall(ServiceName::GlobalApp, ServiceOperation::ReadSelectedProperties, message, in_callback); + m_client->sendRequest(sc); + } + + void BrainCloudGlobalApp::readPropertiesInCategories(const std::vector &categories, IServerCallback * in_callback ) + { + Json::Value message = Json::nullValue; + + message[OperationParam::GlobalAppCategories.getValue()] = JsonUtil::stringVectorToJson(categories); + + ServerCall * sc = new ServerCall(ServiceName::GlobalApp, ServiceOperation::ReadPropertiesInCategories, message, in_callback); + m_client->sendRequest(sc); + } } \ No newline at end of file diff --git a/src/OperationParam.cpp b/src/OperationParam.cpp index 13f1cce2..daaab350 100644 --- a/src/OperationParam.cpp +++ b/src/OperationParam.cpp @@ -370,6 +370,9 @@ namespace BrainCloud const OperationParam OperationParam::UpdateContactEmail = OperationParam("updateContactEmail"); const OperationParam OperationParam::FieldAuthenticationToken = OperationParam("authenticationToken"); + // Global Properties + const OperationParam OperationParam::GlobalAppPropertyNames = OperationParam("propertyNames"); + const OperationParam OperationParam::GlobalAppCategories = OperationParam("categories"); //mail const OperationParam OperationParam::EmailAddress = OperationParam("emailAddress"); diff --git a/src/ServiceOperation.cpp b/src/ServiceOperation.cpp index b74f214d..afe336c2 100644 --- a/src/ServiceOperation.cpp +++ b/src/ServiceOperation.cpp @@ -271,6 +271,8 @@ namespace BrainCloud const ServiceOperation ServiceOperation::UpdateLanguageCode = ServiceOperation("UPDATE_LANGUAGE_CODE"); const ServiceOperation ServiceOperation::ReadProperties = ServiceOperation("READ_PROPERTIES"); + const ServiceOperation ServiceOperation::ReadSelectedProperties = ServiceOperation("READ_SELECTED_PROPERTIES"); + const ServiceOperation ServiceOperation::ReadPropertiesInCategories = ServiceOperation("READ_PROPERTIES_IN_CATEGORIES"); const ServiceOperation ServiceOperation::GetUpdatedFiles = ServiceOperation("GET_UPDATED_FILES"); const ServiceOperation ServiceOperation::GetFileList = ServiceOperation("GET_FILE_LIST"); diff --git a/tests/src/TestBCGlobalApp.cpp b/tests/src/TestBCGlobalApp.cpp index a92b8482..80109dc9 100644 --- a/tests/src/TestBCGlobalApp.cpp +++ b/tests/src/TestBCGlobalApp.cpp @@ -12,4 +12,20 @@ TEST_F(TestBCGlobalApp, ReadProperties) m_bc->getGlobalAppService()->readProperties(&tr); tr.run(m_bc); +} + +TEST_F(TestBCGlobalApp, ReadSelectedProperties) +{ + TestResult tr; + + m_bc->getGlobalAppService()->readSelectedProperties({ "prop1", "prop2", "prop3" }, &tr); + tr.run(m_bc); +} + +TEST_F(TestBCGlobalApp, ReadPropertiesInCategories) +{ + TestResult tr; + + m_bc->getGlobalAppService()->readPropertiesInCategories({ "test" }, &tr); + tr.run(m_bc); } \ No newline at end of file