DefinitelyTyped/types/gapi.client.games/gapi.client.games-tests.ts
Alexey Bolisov 4f8a3d571b Add Google APIs typings (#19083)
* Add Google APIs typings

* [gapi.cliebt.* ] Add version as part of typings name and fix gapi.client tslint errors

* versions should not get their own folders
fixing a few typos
using /** syntax so comments show up in editors
export only actual (last) version for now

* export only actual (last) version for now

* merge namespaces and remove unnecessary namespace qualifiers

* remove namespace qualifier for gapi.client.Request from nested namespaces and change Request base interface to Promise

* disable await-promise rule

* fix collision between gapi.client.Request and Request from nested namespace
disable no-irregular-whitespace rule

* sort properties and namespace resources

* remove empty comments
sort resources amd methods in tests and readme.md

* update 'this is autogenerated file' banner to remove this text from gapi.client namespace hint
use multiline comments when comment has several lines

* implement no-trailing-whitespace, no-padding, max-line-length, await-promise, no-irregular-whitespace rules

* add strictFunctionTypes to tsconfig

* fix "Whitespace within parentheses is not allowed" rule

* fix ts-lint rules

* fixes

* remove deprecated replicapool and replicapoolupdater api

* fix no-irregular-whitespace

* fix no-irregular-whitespace
2017-10-09 14:55:04 -07:00

403 lines
18 KiB
TypeScript

/* This is stub file for gapi.client.{{=it.name}} definition tests */
/* IMPORTANT.
* This file was automatically generated by https://github.com/Bolisov/google-api-typings-generator. Please do not edit it manually.
* In case of any problems please post issue to https://github.com/Bolisov/google-api-typings-generator
**/
gapi.load('client', () => {
/** now we can use gapi.client */
gapi.client.load('games', 'v1', () => {
/** now we can use gapi.client.games */
/** don't forget to authenticate your client before sending any request to resources: */
/** declare client_id registered in Google Developers Console */
const client_id = '<<PUT YOUR CLIENT ID HERE>>';
const scope = [
/** View and manage its own configuration data in your Google Drive */
'https://www.googleapis.com/auth/drive.appdata',
/** Share your Google+ profile information and view and manage your game activity */
'https://www.googleapis.com/auth/games',
/** Know the list of people in your circles, your age range, and language */
'https://www.googleapis.com/auth/plus.login',
];
const immediate = true;
gapi.auth.authorize({ client_id, scope, immediate }, authResult => {
if (authResult && !authResult.error) {
/** handle succesfull authorization */
run();
} else {
/** handle authorization error */
}
});
run();
});
async function run() {
/** Lists all the achievement definitions for your application. */
await gapi.client.achievementDefinitions.list({
consistencyToken: "consistencyToken",
language: "language",
maxResults: 3,
pageToken: "pageToken",
});
/** Increments the steps of the achievement with the given ID for the currently authenticated player. */
await gapi.client.achievements.increment({
achievementId: "achievementId",
consistencyToken: "consistencyToken",
requestId: "requestId",
stepsToIncrement: 4,
});
/** Lists the progress for all your application's achievements for the currently authenticated player. */
await gapi.client.achievements.list({
consistencyToken: "consistencyToken",
language: "language",
maxResults: 3,
pageToken: "pageToken",
playerId: "playerId",
state: "state",
});
/** Sets the state of the achievement with the given ID to REVEALED for the currently authenticated player. */
await gapi.client.achievements.reveal({
achievementId: "achievementId",
consistencyToken: "consistencyToken",
});
/**
* Sets the steps for the currently authenticated player towards unlocking an achievement. If the steps parameter is less than the current number of steps
* that the player already gained for the achievement, the achievement is not modified.
*/
await gapi.client.achievements.setStepsAtLeast({
achievementId: "achievementId",
consistencyToken: "consistencyToken",
steps: 3,
});
/** Unlocks this achievement for the currently authenticated player. */
await gapi.client.achievements.unlock({
achievementId: "achievementId",
consistencyToken: "consistencyToken",
});
/** Updates multiple achievements for the currently authenticated player. */
await gapi.client.achievements.updateMultiple({
consistencyToken: "consistencyToken",
});
/**
* Retrieves the metadata of the application with the given ID. If the requested application is not available for the specified platformType, the returned
* response will not include any instance data.
*/
await gapi.client.applications.get({
applicationId: "applicationId",
consistencyToken: "consistencyToken",
language: "language",
platformType: "platformType",
});
/** Indicate that the the currently authenticated user is playing your application. */
await gapi.client.applications.played({
consistencyToken: "consistencyToken",
});
/** Verifies the auth token provided with this request is for the application with the specified ID, and returns the ID of the player it was granted for. */
await gapi.client.applications.verify({
applicationId: "applicationId",
consistencyToken: "consistencyToken",
});
/** Returns a list showing the current progress on events in this application for the currently authenticated user. */
await gapi.client.events.listByPlayer({
consistencyToken: "consistencyToken",
language: "language",
maxResults: 3,
pageToken: "pageToken",
});
/** Returns a list of the event definitions in this application. */
await gapi.client.events.listDefinitions({
consistencyToken: "consistencyToken",
language: "language",
maxResults: 3,
pageToken: "pageToken",
});
/** Records a batch of changes to the number of times events have occurred for the currently authenticated user of this application. */
await gapi.client.events.record({
consistencyToken: "consistencyToken",
language: "language",
});
/** Retrieves the metadata of the leaderboard with the given ID. */
await gapi.client.leaderboards.get({
consistencyToken: "consistencyToken",
language: "language",
leaderboardId: "leaderboardId",
});
/** Lists all the leaderboard metadata for your application. */
await gapi.client.leaderboards.list({
consistencyToken: "consistencyToken",
language: "language",
maxResults: 3,
pageToken: "pageToken",
});
/** Return the metagame configuration data for the calling application. */
await gapi.client.metagame.getMetagameConfig({
consistencyToken: "consistencyToken",
});
/** List play data aggregated per category for the player corresponding to playerId. */
await gapi.client.metagame.listCategoriesByPlayer({
collection: "collection",
consistencyToken: "consistencyToken",
language: "language",
maxResults: 4,
pageToken: "pageToken",
playerId: "playerId",
});
/** Retrieves the Player resource with the given ID. To retrieve the player for the currently authenticated user, set playerId to me. */
await gapi.client.players.get({
consistencyToken: "consistencyToken",
language: "language",
playerId: "playerId",
});
/** Get the collection of players for the currently authenticated user. */
await gapi.client.players.list({
collection: "collection",
consistencyToken: "consistencyToken",
language: "language",
maxResults: 4,
pageToken: "pageToken",
});
/** Removes a push token for the current user and application. Removing a non-existent push token will report success. */
await gapi.client.pushtokens.remove({
consistencyToken: "consistencyToken",
});
/** Registers a push token for the current user and application. */
await gapi.client.pushtokens.update({
consistencyToken: "consistencyToken",
});
/**
* Report that a reward for the milestone corresponding to milestoneId for the quest corresponding to questId has been claimed by the currently authorized
* user.
*/
await gapi.client.questMilestones.claim({
consistencyToken: "consistencyToken",
milestoneId: "milestoneId",
questId: "questId",
requestId: "requestId",
});
/** Indicates that the currently authorized user will participate in the quest. */
await gapi.client.quests.accept({
consistencyToken: "consistencyToken",
language: "language",
questId: "questId",
});
/** Get a list of quests for your application and the currently authenticated player. */
await gapi.client.quests.list({
consistencyToken: "consistencyToken",
language: "language",
maxResults: 3,
pageToken: "pageToken",
playerId: "playerId",
});
/** Checks whether the games client is out of date. */
await gapi.client.revisions.check({
clientRevision: "clientRevision",
consistencyToken: "consistencyToken",
});
/** Create a room. For internal use by the Games SDK only. Calling this method directly is unsupported. */
await gapi.client.rooms.create({
consistencyToken: "consistencyToken",
language: "language",
});
/** Decline an invitation to join a room. For internal use by the Games SDK only. Calling this method directly is unsupported. */
await gapi.client.rooms.decline({
consistencyToken: "consistencyToken",
language: "language",
roomId: "roomId",
});
/** Dismiss an invitation to join a room. For internal use by the Games SDK only. Calling this method directly is unsupported. */
await gapi.client.rooms.dismiss({
consistencyToken: "consistencyToken",
roomId: "roomId",
});
/** Get the data for a room. */
await gapi.client.rooms.get({
consistencyToken: "consistencyToken",
language: "language",
roomId: "roomId",
});
/** Join a room. For internal use by the Games SDK only. Calling this method directly is unsupported. */
await gapi.client.rooms.join({
consistencyToken: "consistencyToken",
language: "language",
roomId: "roomId",
});
/** Leave a room. For internal use by the Games SDK only. Calling this method directly is unsupported. */
await gapi.client.rooms.leave({
consistencyToken: "consistencyToken",
language: "language",
roomId: "roomId",
});
/** Returns invitations to join rooms. */
await gapi.client.rooms.list({
consistencyToken: "consistencyToken",
language: "language",
maxResults: 3,
pageToken: "pageToken",
});
/** Updates sent by a client reporting the status of peers in a room. For internal use by the Games SDK only. Calling this method directly is unsupported. */
await gapi.client.rooms.reportStatus({
consistencyToken: "consistencyToken",
language: "language",
roomId: "roomId",
});
/**
* Get high scores, and optionally ranks, in leaderboards for the currently authenticated player. For a specific time span, leaderboardId can be set to
* ALL to retrieve data for all leaderboards in a given time span.
* NOTE: You cannot ask for 'ALL' leaderboards and 'ALL' timeSpans in the same request; only one parameter may be set to 'ALL'.
*/
await gapi.client.scores.get({
consistencyToken: "consistencyToken",
includeRankType: "includeRankType",
language: "language",
leaderboardId: "leaderboardId",
maxResults: 5,
pageToken: "pageToken",
playerId: "playerId",
timeSpan: "timeSpan",
});
/** Lists the scores in a leaderboard, starting from the top. */
await gapi.client.scores.list({
collection: "collection",
consistencyToken: "consistencyToken",
language: "language",
leaderboardId: "leaderboardId",
maxResults: 5,
pageToken: "pageToken",
timeSpan: "timeSpan",
});
/** Lists the scores in a leaderboard around (and including) a player's score. */
await gapi.client.scores.listWindow({
collection: "collection",
consistencyToken: "consistencyToken",
language: "language",
leaderboardId: "leaderboardId",
maxResults: 5,
pageToken: "pageToken",
resultsAbove: 7,
returnTopIfAbsent: true,
timeSpan: "timeSpan",
});
/** Submits a score to the specified leaderboard. */
await gapi.client.scores.submit({
consistencyToken: "consistencyToken",
language: "language",
leaderboardId: "leaderboardId",
score: "score",
scoreTag: "scoreTag",
});
/** Submits multiple scores to leaderboards. */
await gapi.client.scores.submitMultiple({
consistencyToken: "consistencyToken",
language: "language",
});
/** Retrieves the metadata for a given snapshot ID. */
await gapi.client.snapshots.get({
consistencyToken: "consistencyToken",
language: "language",
snapshotId: "snapshotId",
});
/** Retrieves a list of snapshots created by your application for the player corresponding to the player ID. */
await gapi.client.snapshots.list({
consistencyToken: "consistencyToken",
language: "language",
maxResults: 3,
pageToken: "pageToken",
playerId: "playerId",
});
/** Cancel a turn-based match. */
await gapi.client.turnBasedMatches.cancel({
consistencyToken: "consistencyToken",
matchId: "matchId",
});
/** Create a turn-based match. */
await gapi.client.turnBasedMatches.create({
consistencyToken: "consistencyToken",
language: "language",
});
/** Decline an invitation to play a turn-based match. */
await gapi.client.turnBasedMatches.decline({
consistencyToken: "consistencyToken",
language: "language",
matchId: "matchId",
});
/** Dismiss a turn-based match from the match list. The match will no longer show up in the list and will not generate notifications. */
await gapi.client.turnBasedMatches.dismiss({
consistencyToken: "consistencyToken",
matchId: "matchId",
});
/**
* Finish a turn-based match. Each player should make this call once, after all results are in. Only the player whose turn it is may make the first call
* to Finish, and can pass in the final match state.
*/
await gapi.client.turnBasedMatches.finish({
consistencyToken: "consistencyToken",
language: "language",
matchId: "matchId",
});
/** Get the data for a turn-based match. */
await gapi.client.turnBasedMatches.get({
consistencyToken: "consistencyToken",
includeMatchData: true,
language: "language",
matchId: "matchId",
});
/** Join a turn-based match. */
await gapi.client.turnBasedMatches.join({
consistencyToken: "consistencyToken",
language: "language",
matchId: "matchId",
});
/** Leave a turn-based match when it is not the current player's turn, without canceling the match. */
await gapi.client.turnBasedMatches.leave({
consistencyToken: "consistencyToken",
language: "language",
matchId: "matchId",
});
/** Leave a turn-based match during the current player's turn, without canceling the match. */
await gapi.client.turnBasedMatches.leaveTurn({
consistencyToken: "consistencyToken",
language: "language",
matchId: "matchId",
matchVersion: 4,
pendingParticipantId: "pendingParticipantId",
});
/** Returns turn-based matches the player is or was involved in. */
await gapi.client.turnBasedMatches.list({
consistencyToken: "consistencyToken",
includeMatchData: true,
language: "language",
maxCompletedMatches: 4,
maxResults: 5,
pageToken: "pageToken",
});
/**
* Create a rematch of a match that was previously completed, with the same participants. This can be called by only one player on a match still in their
* list; the player must have called Finish first. Returns the newly created match; it will be the caller's turn.
*/
await gapi.client.turnBasedMatches.rematch({
consistencyToken: "consistencyToken",
language: "language",
matchId: "matchId",
requestId: "requestId",
});
/**
* Returns turn-based matches the player is or was involved in that changed since the last sync call, with the least recent changes coming first. Matches
* that should be removed from the local cache will have a status of MATCH_DELETED.
*/
await gapi.client.turnBasedMatches.sync({
consistencyToken: "consistencyToken",
includeMatchData: true,
language: "language",
maxCompletedMatches: 4,
maxResults: 5,
pageToken: "pageToken",
});
/** Commit the results of a player turn. */
await gapi.client.turnBasedMatches.takeTurn({
consistencyToken: "consistencyToken",
language: "language",
matchId: "matchId",
});
}
});