@leoua/coc-api
Version:
Yet another Clash of Clans API, but with TS support
32 lines (31 loc) • 1.45 kB
JavaScript
;
/// <reference path="../../../types/types.d.ts"/>
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
class PlayerTag {
static get(api, playerTag, params) {
return __awaiter(this, void 0, void 0, function* () {
if (!playerTag.startsWith('#')) {
playerTag = `#${playerTag}`;
}
playerTag = encodeURIComponent(playerTag);
try {
const res = yield api.post(this.path.replace('{playerTag}', playerTag), params);
return res.data;
}
catch (err) {
throw err;
}
});
}
}
exports.default = PlayerTag;
PlayerTag.path = '/players/{playerTag}/verifytoken';