@varandas/clash-royale-api
Version:
A Clash Royale API official wrapper for seamless integration with your applications.
42 lines • 1.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPlayerBattleLog = exports.getPlayerUpcomingChests = exports.getPlayerByTag = void 0;
/**
* Get information about a single player by player tag.
* Player tags can be found either in game or by from clan member lists.
*
* Note that player tags start with hash character
* '#' and that needs to be URL-encoded properly to work in URL,
* so for example player tag '#2ABC' would become '%232ABC' in the URL.
*
* @param {string} tag
* @param {AxiosInstance} apiClient
*/
const getPlayerByTag = async (tag, apiClient) => {
const player = await apiClient.get(`/players/${encodeURIComponent(tag)}`);
return player.data;
};
exports.getPlayerByTag = getPlayerByTag;
/**
* Get list of reward chests that the player will receive next in the game.
*
* @param {string} tag
* @param {AxiosInstance} apiClient
*/
const getPlayerUpcomingChests = async (tag, apiClient) => {
const upcomingChests = await apiClient.get(`/players/${encodeURIComponent(tag)}/upcomingchests`);
return upcomingChests.data.items;
};
exports.getPlayerUpcomingChests = getPlayerUpcomingChests;
/**
* Get list of recent battle results for a player.
*
* @param {string} tag
* @param {AxiosInstance} apiClient
*/
const getPlayerBattleLog = async (tag, apiClient) => {
const playerBattleLog = await apiClient.get(`/players/${encodeURIComponent(tag)}/battlelog`);
return playerBattleLog.data;
};
exports.getPlayerBattleLog = getPlayerBattleLog;
//# sourceMappingURL=players.endpoint.js.map