Skip to content

Commit

Permalink
https://api.playfab.com/releaseNotes/#160912
Browse files Browse the repository at this point in the history
  • Loading branch information
pgilmorepf committed Sep 13, 2016
2 parents 6e34c3f + b68054c commit ff9fbdb
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 17 deletions.
18 changes: 10 additions & 8 deletions PlayFabApiTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var PlayFabApiTests = {
testNumber: null // Used by several tests
},
testConstants: {
TEST_KEY: "testCounter",
TEST_DATA_KEY: "testCounter",
TEST_STAT_NAME: "str",
CHAR_TEST_TYPE: "Fighter"
},
Expand All @@ -44,7 +44,7 @@ var PlayFabApiTests = {
},

LoginTests: function () {
// All tests run completely synchronously, which is a bit tricky.
// All tests run in parallel, which is a bit tricky.
// Some test rely on data loaded from other tests, and there's no super easy to force tests to be sequential/dependent
// In fact, most of the tests return here before they're done, and report back success/fail in some arbitrary future

Expand Down Expand Up @@ -147,6 +147,8 @@ var PlayFabApiTests = {
var invalidDone = assert.async();

var invalidRequest = {
// Currently, you need to look up the correct format for this object in the API-docs:
// https://api.playfab.com/Documentation/Client/method/LoginWithEmailAddress
TitleId: PlayFab.settings.titleId,
Email: PlayFabApiTests.titleData.userEmail,
Password: PlayFabApiTests.titleData.userPassword + "INVALID"
Expand Down Expand Up @@ -270,10 +272,10 @@ var PlayFabApiTests = {
var getDataCallback2 = function (result, error) {
PlayFabApiTests.VerifyNullError(result, error, assert, "Testing GetUserData result");
assert.ok(result.data.Data != null, "Testing GetUserData Data");
assert.ok(result.data.Data.hasOwnProperty(PlayFabApiTests.testConstants.TEST_KEY), "Testing GetUserData DataKey");
assert.ok(result.data.Data.hasOwnProperty(PlayFabApiTests.testConstants.TEST_DATA_KEY), "Testing GetUserData DataKey");

var actualtestNumber = parseInt(result.data.Data[PlayFabApiTests.testConstants.TEST_KEY].Value, 10);
var timeUpdated = new Date(result.data.Data[PlayFabApiTests.testConstants.TEST_KEY].LastUpdated);
var actualtestNumber = parseInt(result.data.Data[PlayFabApiTests.testConstants.TEST_DATA_KEY].Value, 10);
var timeUpdated = new Date(result.data.Data[PlayFabApiTests.testConstants.TEST_DATA_KEY].LastUpdated);

var now = Date.now();
var testMin = now - (1000 * 60 * 5);
Expand All @@ -292,16 +294,16 @@ var PlayFabApiTests = {
PlayFabApiTests.VerifyNullError(result, error, assert, "Testing GetUserData result");
assert.ok(result.data.Data != null, "Testing GetUserData Data");

var hasData = result.data.Data.hasOwnProperty(PlayFabApiTests.testConstants.TEST_KEY);
PlayFabApiTests.testData.testNumber = !hasData ? 1 : parseInt(result.data.Data[PlayFabApiTests.testConstants.TEST_KEY].Value, 10);
var hasData = result.data.Data.hasOwnProperty(PlayFabApiTests.testConstants.TEST_DATA_KEY);
PlayFabApiTests.testData.testNumber = !hasData ? 1 : parseInt(result.data.Data[PlayFabApiTests.testConstants.TEST_DATA_KEY].Value, 10);
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 updateDataRequest = {
// Currently, you need to look up the correct format for this object in the API-docs:
// https://api.playfab.com/Documentation/Client/method/UpdateUserData
Data: {} // Can't pre-define properties because the param-name is in a string
};
updateDataRequest.Data[PlayFabApiTests.testConstants.TEST_KEY] = PlayFabApiTests.testData.testNumber;
updateDataRequest.Data[PlayFabApiTests.testConstants.TEST_DATA_KEY] = PlayFabApiTests.testData.testNumber;
PlayFabClientSDK.UpdateUserData(updateDataRequest, PlayFabApiTests.CallbackWrapper("updateDataCallback", updateDataCallback, assert));
get1Done();
};
Expand Down
10 changes: 8 additions & 2 deletions PlayFabSDK/PlayFabAdminApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ if(!PlayFab.settings) {
if(!PlayFab._internalSettings) {
PlayFab._internalSettings = {
sessionTicket: null,
sdkVersion: "0.28.160829",
buildIdentifier: "jbuild_javascriptsdk_0",
sdkVersion: "0.29.160912",
buildIdentifier: "jbuild_javascriptsdk_1",
productionServerUrl: ".playfabapi.com",
logicServerUrl: null,

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

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

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

Expand Down
4 changes: 2 additions & 2 deletions PlayFabSDK/PlayFabClientApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ if(!PlayFab.settings) {
if(!PlayFab._internalSettings) {
PlayFab._internalSettings = {
sessionTicket: null,
sdkVersion: "0.28.160829",
buildIdentifier: "jbuild_javascriptsdk_0",
sdkVersion: "0.29.160912",
buildIdentifier: "jbuild_javascriptsdk_1",
productionServerUrl: ".playfabapi.com",
logicServerUrl: null,

Expand Down
4 changes: 2 additions & 2 deletions PlayFabSDK/PlayFabMatchmakerApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ if(!PlayFab.settings) {
if(!PlayFab._internalSettings) {
PlayFab._internalSettings = {
sessionTicket: null,
sdkVersion: "0.28.160829",
buildIdentifier: "jbuild_javascriptsdk_0",
sdkVersion: "0.29.160912",
buildIdentifier: "jbuild_javascriptsdk_1",
productionServerUrl: ".playfabapi.com",
logicServerUrl: null,

Expand Down
10 changes: 8 additions & 2 deletions PlayFabSDK/PlayFabServerApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ if(!PlayFab.settings) {
if(!PlayFab._internalSettings) {
PlayFab._internalSettings = {
sessionTicket: null,
sdkVersion: "0.28.160829",
buildIdentifier: "jbuild_javascriptsdk_0",
sdkVersion: "0.29.160912",
buildIdentifier: "jbuild_javascriptsdk_1",
productionServerUrl: ".playfabapi.com",
logicServerUrl: null,

Expand Down Expand Up @@ -673,6 +673,12 @@ PlayFab.ServerApi = {
PlayFab._internalSettings.ExecuteRequest(PlayFab._internalSettings.GetServerUrl() + "/Server/AddPlayerTag", request, "X-SecretKey", PlayFab.settings.developerSecretKey, callback);
},

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

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

Expand Down
65 changes: 64 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,71 @@ Our Developer Success Team can assist with answering any questions as well as pr

[Forums, Support and Knowledge Base](https://community.playfab.com/hc/en-us)

6. Example Usage (Template):
----

```
// In this javascript example, it is assumed your html will include the PlayFab JavaScript Client SDK
// For example, in your html header, add this:
// <script src="https://download.playfab.com/PlayFabClientApi.js"></script>
// You must always set your titleId first
PlayFab.settings.titleId = null; // Set your titleId here. Example: "6195"
// Utility function (We may add this to the core sdk later)
function CompileErrorReport(error) {
if (error == null)
return "";
var fullErrors = error.errorMessage;
for (var paramName in error.errorDetails)
for (var msgIdx in error.errorDetails[paramName])
fullErrors += "\n" + paramName + ": " + error.errorDetails[paramName][msgIdx];
return fullErrors;
}
// Define a callback function (In this case for any PlayFab-Login)
function OnLogin(response, error) {
if (response && response["code"] == 200) {
console.log("Login Successful: " + response.data.PlayFabId)
}
else {
console.log("LoginWithEmailAddress Failed: \n" + CompileErrorReport(error))
}
}
// Username and email is a typical login for Web-Pages
function ExampleLoginWithEmailAddress(email, password)
{
// Request JSON
var loginRequest = {
TitleId: PlayFab.settings.titleId,
"Email": email,
"Password": password
};
// https://api.playfab.com/Documentation/Client/method/LoginWithEmailAddress
PlayFabClientSDK.LoginWithEmailAddress(loginRequest, OnLogin);
}
// CustomId should only be used for testing or evaluating PlayFab, but it can be any string
function ExampleLoginWithCustomId(customId) {
// Request JSON
var loginRequest = {
TitleId: PlayFab.settings.titleId,
CustomId: PlayFab._internalSettings.buildIdentifier,
CreateAccount: true
};
// https://api.playfab.com/Documentation/Client/method/LoginWithCustomID
PlayFabClientSDK.LoginWithCustomID(loginRequest, OnLogin);
}
```


7. Acknowledgements
----
Example Usage provided by [dylanh724](https://www.github.com/dylanh724)


6. Copyright and Licensing Information:
8. Copyright and Licensing Information:
----
Apache License --
Version 2.0, January 2004
Expand Down

0 comments on commit ff9fbdb

Please sign in to comment.