Skip to content

Commit

Permalink
https://api.playfab.com/releaseNotes/#160822
Browse files Browse the repository at this point in the history
  • Loading branch information
pgilmorepf committed Aug 22, 2016
2 parents 48c50db + de97c44 commit 7f78de8
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 21 deletions.
37 changes: 20 additions & 17 deletions PlayFabApiTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var PlayFabApiTests = {
} else {
// Continue with other tests that require login
QUnit.test("UserDataApi", PlayFabApiTests.UserDataApi);
QUnit.test("UserStatisticsApi", PlayFabApiTests.UserStatisticsApi);
QUnit.test("PlayerStatisticsApi", PlayFabApiTests.PlayerStatisticsApi);
QUnit.test("UserCharacter", PlayFabApiTests.UserCharacter);
QUnit.test("LeaderBoard", PlayFabApiTests.LeaderBoard);
QUnit.test("AccountInfo", PlayFabApiTests.AccountInfo);
Expand Down Expand Up @@ -317,7 +317,7 @@ var PlayFabApiTests = {
/// Verify that the data is saved correctly, and that specific types are tested
/// Parameter types tested: Dictionary<string, int>
/// </summary>
UserStatisticsApi: function (assert) {
PlayerStatisticsApi: function (assert) {
var getStatsRequest = {}; // null also works

// This test is always exactly 3 async calls
Expand All @@ -326,40 +326,43 @@ var PlayFabApiTests = {
var get2Done = assert.async();

var getStatsCallback2 = function (result, error) {
PlayFabApiTests.VerifyNullError(result, error, assert, "Testing GetUserStats result");
assert.ok(result.data.UserStatistics != null, "Testing GetUserData Stats");
assert.ok(result.data.UserStatistics.hasOwnProperty(PlayFabApiTests.testConstants.TEST_STAT_NAME), "Testing GetUserData Stat-value");
PlayFabApiTests.VerifyNullError(result, error, assert, "Testing GetPlayerStats result");
assert.ok(result.data.Statistics != null, "Testing GetUserData Stats");

var actualtestNumber = result.data.UserStatistics[PlayFabApiTests.testConstants.TEST_STAT_NAME];
var actualtestNumber = -1000;
for (var i = 0; i < result.data.Statistics.length; i++)
if (result.data.Statistics[i].StatisticName === PlayFabApiTests.testConstants.TEST_STAT_NAME)
actualtestNumber = result.data.Statistics[i].Value;

assert.equal(PlayFabApiTests.testData.testNumber, actualtestNumber, "Testing incrementing stat: " + PlayFabApiTests.testData.testNumber + "==" + actualtestNumber);
get2Done();
};
var updateStatsCallback = function (result, error) {
PlayFabApiTests.VerifyNullError(result, error, assert, "Testing UpdateUserStats result");
PlayFabClientSDK.GetUserStatistics(getStatsRequest, PlayFabApiTests.CallbackWrapper("getStatsCallback2", getStatsCallback2, assert));
PlayFabApiTests.VerifyNullError(result, error, assert, "Testing UpdatePlayerStats result");
PlayFabClientSDK.GetPlayerStatistics(getStatsRequest, PlayFabApiTests.CallbackWrapper("getStatsCallback2", getStatsCallback2, assert));
updateDone();
};
var getStatsCallback1 = function (result, error) {
PlayFabApiTests.VerifyNullError(result, error, assert, "Testing GetUserStats result");
assert.ok(result.data.UserStatistics != null, "Testing GetUserData Stats");
PlayFabApiTests.VerifyNullError(result, error, assert, "Testing GetPlayerStats result");
assert.ok(result.data.Statistics != null, "Testing GetUserData Stats");

var hasData = result.data.UserStatistics.hasOwnProperty(PlayFabApiTests.testConstants.TEST_STAT_NAME);
PlayFabApiTests.testData.testNumber = !hasData ? 1 : result.data.UserStatistics[PlayFabApiTests.testConstants.TEST_STAT_NAME];
PlayFabApiTests.testData.testNumber = 0;
for (var i = 0; i < result.data.Statistics.length; i++)
if (result.data.Statistics[i].StatisticName === PlayFabApiTests.testConstants.TEST_STAT_NAME)
PlayFabApiTests.testData.testNumber = result.data.Statistics[i].Value;
PlayFabApiTests.testData.testNumber = (PlayFabApiTests.testData.testNumber + 1) % 100; // This test is about the expected value changing - but not testing more complicated issues like bounds

var updateStatsRequest = {
// Currently, you need to look up the correct format for this object in the API-docs:
// https://api.playfab.com/Documentation/Client/method/UpdateUserStatistics
UserStatistics: {} // Can't pre-define properties because the param-name is in a string
// https://api.playfab.com/Documentation/Client/method/UpdatePlayerStatistics
Statistics: [{ StatisticName: PlayFabApiTests.testConstants.TEST_STAT_NAME, Value: PlayFabApiTests.testData.testNumber }]
};
updateStatsRequest.UserStatistics[PlayFabApiTests.testConstants.TEST_STAT_NAME] = PlayFabApiTests.testData.testNumber;
PlayFabClientSDK.UpdateUserStatistics(updateStatsRequest, PlayFabApiTests.CallbackWrapper("updateStatsCallback", updateStatsCallback, assert));
PlayFabClientSDK.UpdatePlayerStatistics(updateStatsRequest, PlayFabApiTests.CallbackWrapper("updateStatsCallback", updateStatsCallback, assert));
get1Done();
};

// Kick off this test process
PlayFabClientSDK.GetUserStatistics(getStatsRequest, PlayFabApiTests.CallbackWrapper("getStatsCallback1", getStatsCallback1, assert));
PlayFabClientSDK.GetPlayerStatistics(getStatsRequest, PlayFabApiTests.CallbackWrapper("getStatsCallback1", getStatsCallback1, assert));
},

/// <summary>
Expand Down
38 changes: 37 additions & 1 deletion PlayFabSDK/PlayFabAdminApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if(!PlayFab.settings) {
if(!PlayFab._internalSettings) {
PlayFab._internalSettings = {
sessionTicket: null,
sdkVersion: "0.26.160815",
sdkVersion: "0.27.160822",
buildIdentifier: "jbuild_javascriptsdk_0",
productionServerUrl: ".playfabapi.com",
logicServerUrl: null,
Expand Down Expand Up @@ -106,24 +106,54 @@ if(!PlayFab._internalSettings) {

PlayFab.AdminApi = {

BanUsers: 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/BanUsers", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

GetUserAccountInfo: 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/GetUserAccountInfo", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

GetUserBans: 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/GetUserBans", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

ResetUsers: 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/ResetUsers", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

RevokeAllBansForUser: 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/RevokeAllBansForUser", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

RevokeBans: 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/RevokeBans", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

SendAccountRecoveryEmail: 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/SendAccountRecoveryEmail", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

UpdateBans: 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/UpdateBans", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

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

Expand Down Expand Up @@ -262,6 +292,12 @@ PlayFab.AdminApi = {
PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Admin/AddVirtualCurrencyTypes", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

DeleteStore: 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/DeleteStore", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

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

Expand Down
2 changes: 1 addition & 1 deletion PlayFabSDK/PlayFabClientApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if(!PlayFab.settings) {
if(!PlayFab._internalSettings) {
PlayFab._internalSettings = {
sessionTicket: null,
sdkVersion: "0.26.160815",
sdkVersion: "0.27.160822",
buildIdentifier: "jbuild_javascriptsdk_0",
productionServerUrl: ".playfabapi.com",
logicServerUrl: null,
Expand Down
2 changes: 1 addition & 1 deletion PlayFabSDK/PlayFabMatchmakerApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if(!PlayFab.settings) {
if(!PlayFab._internalSettings) {
PlayFab._internalSettings = {
sessionTicket: null,
sdkVersion: "0.26.160815",
sdkVersion: "0.27.160822",
buildIdentifier: "jbuild_javascriptsdk_0",
productionServerUrl: ".playfabapi.com",
logicServerUrl: null,
Expand Down
38 changes: 37 additions & 1 deletion PlayFabSDK/PlayFabServerApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if(!PlayFab.settings) {
if(!PlayFab._internalSettings) {
PlayFab._internalSettings = {
sessionTicket: null,
sdkVersion: "0.26.160815",
sdkVersion: "0.27.160822",
buildIdentifier: "jbuild_javascriptsdk_0",
productionServerUrl: ".playfabapi.com",
logicServerUrl: null,
Expand Down Expand Up @@ -112,6 +112,12 @@ PlayFab.ServerApi = {
PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Server/AuthenticateSessionTicket", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

BanUsers: 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/BanUsers", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

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

Expand All @@ -130,12 +136,36 @@ PlayFab.ServerApi = {
PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Server/GetUserAccountInfo", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

GetUserBans: 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/GetUserBans", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

RevokeAllBansForUser: 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/RevokeAllBansForUser", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

RevokeBans: 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/RevokeBans", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

SendPushNotification: 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/SendPushNotification", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

UpdateBans: 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/UpdateBans", 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 Down Expand Up @@ -340,6 +370,12 @@ PlayFab.ServerApi = {
PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Server/GetCharacterInventory", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

GetRandomResultTables: 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/GetRandomResultTables", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

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

Expand Down

0 comments on commit 7f78de8

Please sign in to comment.