Skip to content

Commit

Permalink
Merge pull request #223 from getbraincloud/BCLOUD-9080_Implement-Upda…
Browse files Browse the repository at this point in the history
…teIncomingEventDataIfExists

added updateIncomingEventDataIfExists
  • Loading branch information
bitheadCody authored Aug 13, 2024
2 parents 9a50283 + c416587 commit 79b2ade
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/brainCloudClient-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function BCEvents() {

bc.event.OPERATION_SEND = "SEND";
bc.event.OPERATION_UPDATE_EVENT_DATA = "UPDATE_EVENT_DATA";
bc.event.OPERATION_UPDATE_EVENT_DATA_IF_EXISTS = "UPDATE_EVENT_DATA_IF_EXISTS";
bc.event.OPERATION_DELETE_INCOMING = "DELETE_INCOMING";
bc.event.OPERATION_DELETE_SENT = "DELETE_SENT";
bc.event.OPERATION_GET_EVENTS = "GET_EVENTS";
Expand Down Expand Up @@ -73,6 +74,30 @@ function BCEvents() {
});
};

/**
* Updates an event in the player's incoming event mailbox.
* Identical to updateIncomingEventData method, but will not return an error if the event does not exist
*
* Service Name - Event
* Service Operation - UpdateEventData
*
* @param evId The event id
* @param eventData The user-defined data for this event encoded in JSON.
* @param callback The method to be invoked when the server response is received
*/
bc.event.updateIncomingEventDataIfExists = function(evId, eventData, callback) {
var message = {
evId: evId,
eventData: eventData
};
bc.brainCloudManager.sendRequest({
service: bc.SERVICE_EVENT,
operation: bc.event.OPERATION_UPDATE_EVENT_DATA_IF_EXISTS,
data: message,
callback: callback
});
};

/**
* Delete an event out of the user's incoming mailbox.
*
Expand Down
24 changes: 24 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,19 @@ async function testEvent() {

var eventId;

await setUpWithAuthenticate();
await asyncTest("updateIncomingEventDataIfExistsFalse()", function() {
var nonExistentEventId = "999999999999999999999999"

bc.event.updateIncomingEventDataIfExists(
nonExistentEventId,
{eventDataKey : 118 },
function(result) {
equal(result.status, 200, JSON.stringify(result));
resolve_test();
});
});

await setUpWithAuthenticate();
await asyncTest("sendEvent()", 2, function() {
var sendEventSemi = 0;
Expand Down Expand Up @@ -1526,6 +1539,17 @@ async function testEvent() {
});
});

await setUpWithAuthenticate();
await asyncTest("updateIncomingEventDataIfExistsTrue()", function() {
bc.event.updateIncomingEventDataIfExists(
eventId,
{eventDataKey : 118 },
function(result) {
equal(result.status, 200, JSON.stringify(result));
resolve_test();
});
});

await setUpWithAuthenticate();
await asyncTest("deleteIncomingEvent()", function() {
bc.event.deleteIncomingEvent(
Expand Down

0 comments on commit 79b2ade

Please sign in to comment.