Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BCLOUD-1079 getSelectedProperties/InCategories #182

Merged
merged 1 commit into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions include/braincloud/BrainCloudGlobalApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#pragma once

#include <stddef.h>
#include <vector>
#include <string>

namespace BrainCloud
{
Expand All @@ -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<std::string> &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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

categories :)

* @param in_callback The method to be invoked when the server response is received
*/
void readPropertiesInCategories(const std::vector<std::string> &categories, IServerCallback * in_callback = NULL);

private:
BrainCloudClient * m_client;
};
Expand Down
4 changes: 4 additions & 0 deletions include/braincloud/OperationParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions include/braincloud/ServiceOperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 23 additions & 0 deletions src/BrainCloudGlobalApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) { }
Expand All @@ -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<std::string> &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<std::string> &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);
}
}
3 changes: 3 additions & 0 deletions src/OperationParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions src/ServiceOperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
16 changes: 16 additions & 0 deletions tests/src/TestBCGlobalApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}