Skip to content

Weekly SDK Publish #38

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

Merged
merged 3 commits into from
Feb 15, 2016
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
42 changes: 14 additions & 28 deletions PlayFabApiTest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if (typeof PlayFabClientSDK == 'undefined')
Console.error("PlayFabApiTest requires PlayFabClientApi.js to be pre-loaded.");
console.log("PlayFabApiTest requires PlayFabClientApi.js to be pre-loaded.");
if (typeof PlayFabServerSDK == 'undefined')
Console.error("PlayFabApiTest requires PlayFabServerApi.js to be pre-loaded.");
console.log("PlayFabApiTest requires PlayFabServerApi.js to be pre-loaded.");

var PlayFabApiTests = {
testTitleDataFilename: "testTitleData.json", // TODO: Do not hard code the location of this file (javascript can't really do relative paths either)
Expand Down Expand Up @@ -45,7 +45,6 @@ var PlayFabApiTests = {
QUnit.test("LoginWithAdvertisingId", PlayFabApiTests.LoginWithAdvertisingId);

setTimeout(function () { PlayFabApiTests.PostLoginTests(0); }, 200);
setTimeout(function () { PlayFabApiTests.PostCharacterTests(0); }, 200);
},

PostLoginTests: function (count) {
Expand All @@ -60,23 +59,12 @@ var PlayFabApiTests = {
QUnit.test("UserDataApi", PlayFabApiTests.UserDataApi);
QUnit.test("UserStatisticsApi", PlayFabApiTests.UserStatisticsApi);
QUnit.test("UserCharacter", PlayFabApiTests.UserCharacter);
QUnit.test("LeaderBoard", PlayFabApiTests.LeaderBoard);
QUnit.test("AccountInfo", PlayFabApiTests.AccountInfo);
QUnit.test("CloudScript", PlayFabApiTests.CloudScript);
}
},

PostCharacterTests: function (count) {
if (count > 5)
return;

if (PlayFabApiTests.testData.characterId == null) {
// Wait for characterId
setTimeout(function () { PlayFabApiTests.PostCharacterTests(count + 1); }, 200);
} else {
QUnit.test("LeaderBoard", PlayFabApiTests.LeaderBoard);
}
},

SetUp: function (inputTitleData) {
// All of these must exist for the titleData load to be successful
var titleDataValid = inputTitleData.hasOwnProperty("titleId") && inputTitleData.titleId != null
Expand All @@ -90,7 +78,7 @@ var PlayFabApiTests = {
if (titleDataValid)
PlayFabApiTests.titleData = inputTitleData;
else
window.console.error("testTitleData input file did not parse correctly");
console.log("testTitleData input file did not parse correctly");

PlayFab.settings.titleId = PlayFabApiTests.titleData.titleId;
PlayFab.settings.developerSecretKey = PlayFabApiTests.titleData.developerSecretKey;
Expand All @@ -103,7 +91,7 @@ var PlayFabApiTests = {
try {
Callback(result, error);
} catch (e) {
window.console.error("Exception thrown during " + callbackName + " callback: " + e.toString() + "\n" + e.stack); // Very irritatingly, qunit doesn't report failure results until all async callbacks return, which doesn't always happen when there's an exception
console.log("Exception thrown during " + callbackName + " callback: " + e.toString() + "\n" + e.stack); // Very irritatingly, qunit doesn't report failure results until all async callbacks return, which doesn't always happen when there's an exception
assert.ok(false, "Exception thrown during " + callbackName + " callback: " + e.toString() + "\n" + e.stack);
}
};
Expand All @@ -114,7 +102,7 @@ var PlayFabApiTests = {
try {
Callback();
} catch (e) {
window.console.error("Exception thrown during " + callbackName + " callback: " + e.toString() + "\n" + e.stack); // Very irritatingly, qunit doesn't report failure results until all async callbacks return, which doesn't always happen when there's an exception
console.log("Exception thrown during " + callbackName + " callback: " + e.toString() + "\n" + e.stack); // Very irritatingly, qunit doesn't report failure results until all async callbacks return, which doesn't always happen when there's an exception
assert.ok(false, "Exception thrown during " + callbackName + " callback: " + e.toString() + "\n" + e.stack);
}
};
Expand Down Expand Up @@ -411,34 +399,32 @@ var PlayFabApiTests = {
};
var serverRequest = {
MaxResultsCount: 3,
PlayFabId: PlayFabApiTests.testData.playFabId,
CharacterId: PlayFabApiTests.testData.characterId,
StatisticName: PlayFabApiTests.testConstants.TEST_STAT_NAME,
};
var lbDoneC = assert.async();
var lbDoneS = assert.async();

var GetLeaderboardCallback_C = function (result, error) {
var getLeaderboardCallbackC = function (result, error) {
PlayFabApiTests.VerifyNullError(result, error, assert, "Testing GetLeaderboard result");
if (result != null) {
assert.ok(result.data.Leaderboard != null, "Testing GetLeaderboard content");
assert.ok(result.data.Leaderboard.length > 0, "Testing GetLeaderboard content-length");
}

lbDone_C();
lbDoneC();
};
var GetLeaderboardCallback_S = function (result, error) {
var getLeaderboardCallbackS = function (result, error) {
PlayFabApiTests.VerifyNullError(result, error, assert, "Testing GetLeaderboard result");
if (result != null) {
assert.ok(result.data.Leaderboard != null, "Testing GetLeaderboard content");
assert.ok(result.data.Leaderboard.length > 0, "Testing GetLeaderboard content-length");
}

lbDone_S();
lbDoneS();
};

var lbDone_C = assert.async();
PlayFabClientSDK.GetLeaderboardAroundCurrentUser(clientRequest, PlayFabApiTests.CallbackWrapper("GetLeaderboardCallback_C", GetLeaderboardCallback_C, assert));
var lbDone_S = assert.async();
PlayFabServerSDK.GetLeaderboardAroundCharacter(serverRequest, PlayFabApiTests.CallbackWrapper("GetLeaderboardCallback_S", GetLeaderboardCallback_S, assert));
PlayFabClientSDK.GetLeaderboard(clientRequest, PlayFabApiTests.CallbackWrapper("getLeaderboardCallbackC", getLeaderboardCallbackC, assert));
PlayFabServerSDK.GetLeaderboard(serverRequest, PlayFabApiTests.CallbackWrapper("getLeaderboardCallbackS", getLeaderboardCallbackS, assert));
},

/// <summary>
Expand Down
30 changes: 30 additions & 0 deletions PlayFabSDK/PlayFabAdminApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ PlayFab.AdminApi = {
PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Admin/UpdateUserTitleDisplayName", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

CreatePlayerStatisticDefinition: function (request, callback) {
if (PlayFab.settings.developerSecretKey == null) throw "Must have PlayFab.settings.developerSecretKey set to call this method";

PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Admin/CreatePlayerStatisticDefinition", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

DeleteUsers: function (request, callback) {
if (PlayFab.settings.developerSecretKey == null) throw "Must have PlayFab.settings.developerSecretKey set to call this method";

Expand All @@ -140,6 +146,18 @@ PlayFab.AdminApi = {
PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Admin/GetDataReport", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

GetPlayerStatisticDefinitions: function (request, callback) {
if (PlayFab.settings.developerSecretKey == null) throw "Must have PlayFab.settings.developerSecretKey set to call this method";

PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Admin/GetPlayerStatisticDefinitions", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

GetPlayerStatisticVersions: function (request, callback) {
if (PlayFab.settings.developerSecretKey == null) throw "Must have PlayFab.settings.developerSecretKey set to call this method";

PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Admin/GetPlayerStatisticVersions", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

GetUserData: function (request, callback) {
if (PlayFab.settings.developerSecretKey == null) throw "Must have PlayFab.settings.developerSecretKey set to call this method";

Expand Down Expand Up @@ -176,12 +194,24 @@ PlayFab.AdminApi = {
PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Admin/GetUserReadOnlyData", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

IncrementPlayerStatisticVersion: function (request, callback) {
if (PlayFab.settings.developerSecretKey == null) throw "Must have PlayFab.settings.developerSecretKey set to call this method";

PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Admin/IncrementPlayerStatisticVersion", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

ResetUserStatistics: function (request, callback) {
if (PlayFab.settings.developerSecretKey == null) throw "Must have PlayFab.settings.developerSecretKey set to call this method";

PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Admin/ResetUserStatistics", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

UpdatePlayerStatisticDefinition: function (request, callback) {
if (PlayFab.settings.developerSecretKey == null) throw "Must have PlayFab.settings.developerSecretKey set to call this method";

PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Admin/UpdatePlayerStatisticDefinition", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

UpdateUserData: function (request, callback) {
if (PlayFab.settings.developerSecretKey == null) throw "Must have PlayFab.settings.developerSecretKey set to call this method";

Expand Down
18 changes: 18 additions & 0 deletions PlayFabSDK/PlayFabClientApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,12 @@ PlayFab.ClientApi = {
PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Client/GetLeaderboardAroundPlayer", request, "X-Authorization", PlayFab._internalSettings.sessionTicket, callback);
},

GetPlayerStatistics: function (request, callback) {
if (PlayFab._internalSettings.sessionTicket == null) throw "Must be logged in to call this method";

PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Client/GetPlayerStatistics", request, "X-Authorization", PlayFab._internalSettings.sessionTicket, callback);
},

GetUserData: function (request, callback) {
if (PlayFab._internalSettings.sessionTicket == null) throw "Must be logged in to call this method";

Expand Down Expand Up @@ -543,6 +549,12 @@ PlayFab.ClientApi = {
PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Client/GetUserStatistics", request, "X-Authorization", PlayFab._internalSettings.sessionTicket, callback);
},

UpdatePlayerStatistics: function (request, callback) {
if (PlayFab._internalSettings.sessionTicket == null) throw "Must be logged in to call this method";

PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Client/UpdatePlayerStatistics", request, "X-Authorization", PlayFab._internalSettings.sessionTicket, callback);
},

UpdateUserData: function (request, callback) {
if (PlayFab._internalSettings.sessionTicket == null) throw "Must be logged in to call this method";

Expand Down Expand Up @@ -657,6 +669,12 @@ PlayFab.ClientApi = {
PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Client/SubtractUserVirtualCurrency", request, "X-Authorization", PlayFab._internalSettings.sessionTicket, callback);
},

UnlockContainerInstance: function (request, callback) {
if (PlayFab._internalSettings.sessionTicket == null) throw "Must be logged in to call this method";

PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Client/UnlockContainerInstance", request, "X-Authorization", PlayFab._internalSettings.sessionTicket, callback);
},

UnlockContainerItem: function (request, callback) {
if (PlayFab._internalSettings.sessionTicket == null) throw "Must be logged in to call this method";

Expand Down
12 changes: 12 additions & 0 deletions PlayFabSDK/PlayFabServerApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,18 @@ PlayFab.ServerApi = {
PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Server/SubtractUserVirtualCurrency", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

UnlockContainerInstance: function (request, callback) {
if (PlayFab.settings.developerSecretKey == null) throw "Must have PlayFab.settings.developerSecretKey set to call this method";

PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Server/UnlockContainerInstance", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

UnlockContainerItem: function (request, callback) {
if (PlayFab.settings.developerSecretKey == null) throw "Must have PlayFab.settings.developerSecretKey set to call this method";

PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Server/UnlockContainerItem", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

UpdateUserInventoryItemCustomData: function (request, callback) {
if (PlayFab.settings.developerSecretKey == null) throw "Must have PlayFab.settings.developerSecretKey set to call this method";

Expand Down