clashofclans.js 2.0.0-dev.30ea324 → 2.0.0-dev.7768cb1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -4
- package/README.md +5 -5
- package/dist/client/Client.d.ts +55 -25
- package/dist/client/Client.js +65 -41
- package/dist/client/EventManager.d.ts +46 -20
- package/dist/client/EventManager.js +97 -51
- package/dist/rest/HTTPError.d.ts +17 -1
- package/dist/rest/HTTPError.js +26 -7
- package/dist/rest/RESTManager.d.ts +50 -1
- package/dist/rest/RESTManager.js +25 -1
- package/dist/rest/RequestHandler.d.ts +84 -3
- package/dist/rest/RequestHandler.js +51 -19
- package/dist/rest/Throttler.d.ts +0 -4
- package/dist/struct/Clan.d.ts +2 -1
- package/dist/struct/Clan.js +2 -2
- package/dist/struct/ClanMember.d.ts +2 -1
- package/dist/struct/ClanMember.js +2 -2
- package/dist/struct/ClanWar.d.ts +6 -4
- package/dist/struct/ClanWar.js +17 -3
- package/dist/struct/ClanWarLeagueGroup.d.ts +5 -3
- package/dist/struct/ClanWarLeagueGroup.js +12 -10
- package/dist/struct/ClanWarLog.d.ts +2 -2
- package/dist/struct/ClanWarLog.js +2 -2
- package/dist/struct/Player.d.ts +2 -1
- package/dist/struct/Player.js +7 -5
- package/dist/struct/PlayerClan.d.ts +2 -1
- package/dist/struct/PlayerClan.js +2 -2
- package/dist/struct/Unit.d.ts +37 -4
- package/dist/struct/Unit.js +49 -9
- package/dist/types/index.d.ts +3 -5
- package/dist/util/Constants.d.ts +5 -0
- package/dist/util/Constants.js +6 -1
- package/dist/util/Util.js +3 -1
- package/dist/util/raw.json +1 -0
- package/package.json +5 -5
|
@@ -4,7 +4,7 @@ exports.EventManager = void 0;
|
|
|
4
4
|
const HTTPError_1 = require("../rest/HTTPError");
|
|
5
5
|
const Constants_1 = require("../util/Constants");
|
|
6
6
|
const Util_1 = require("../util/Util");
|
|
7
|
-
/** Represents Event Manager of the {@link Client}
|
|
7
|
+
/** Represents Event Manager of the {@link Client}. */
|
|
8
8
|
class EventManager {
|
|
9
9
|
constructor(client) {
|
|
10
10
|
this.client = client;
|
|
@@ -31,54 +31,65 @@ class EventManager {
|
|
|
31
31
|
this.warUpdateHandler();
|
|
32
32
|
return Promise.resolve(this.client.eventNames());
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
/** Add clan tags to clan events. */
|
|
35
|
+
addClans(tags) {
|
|
36
|
+
for (const tag of Array.isArray(tags) ? tags : [tags]) {
|
|
36
37
|
this._clanTags.add(this.client.util.parseTag(tag));
|
|
37
38
|
}
|
|
38
39
|
return this;
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
/** Delete clan tags from clan events. */
|
|
42
|
+
deleteClans(tags) {
|
|
43
|
+
for (const tag of Array.isArray(tags) ? tags : [tags]) {
|
|
44
|
+
const key = this.client.util.parseTag(tag);
|
|
45
|
+
this._clans.delete(key);
|
|
46
|
+
this._clanTags.delete(key);
|
|
43
47
|
}
|
|
44
48
|
return this;
|
|
45
49
|
}
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
/** Add player tags for player events. */
|
|
51
|
+
addPlayers(tags) {
|
|
52
|
+
for (const tag of Array.isArray(tags) ? tags : [tags]) {
|
|
48
53
|
this._playerTags.add(this.client.util.parseTag(tag));
|
|
49
54
|
}
|
|
50
55
|
return this;
|
|
51
56
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
/** Delete player tags from player events. */
|
|
58
|
+
deletePlayers(tags) {
|
|
59
|
+
for (const tag of Array.isArray(tags) ? tags : [tags]) {
|
|
60
|
+
const key = this.client.util.parseTag(tag);
|
|
61
|
+
this._players.delete(key);
|
|
62
|
+
this._playerTags.delete(key);
|
|
55
63
|
}
|
|
56
64
|
return this;
|
|
57
65
|
}
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
/** Add clan tags for war events. */
|
|
67
|
+
addWars(tags) {
|
|
68
|
+
for (const tag of Array.isArray(tags) ? tags : [tags]) {
|
|
60
69
|
this._warTags.add(this.client.util.parseTag(tag));
|
|
61
70
|
}
|
|
62
71
|
return this;
|
|
63
72
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
73
|
+
/** Delete clan tags from war events. */
|
|
74
|
+
deleteWars(tags) {
|
|
75
|
+
for (const tag of Array.isArray(tags) ? tags : [tags]) {
|
|
76
|
+
const key = this.client.util.parseTag(tag);
|
|
77
|
+
this._wars.delete(`${key}:${1}`);
|
|
78
|
+
this._wars.delete(`${key}:${2}`);
|
|
79
|
+
this._warTags.delete(key);
|
|
67
80
|
}
|
|
68
81
|
return this;
|
|
69
82
|
}
|
|
70
83
|
/**
|
|
71
|
-
* Set your own custom event.
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* @param event.filter - Filter of this event. Must return a boolean value.
|
|
84
|
+
* Set your own custom clan event.
|
|
85
|
+
*
|
|
86
|
+
* In order to emit the custom event, you must have this filter function that returns a boolean.
|
|
75
87
|
*
|
|
76
88
|
* @example
|
|
77
89
|
* ```js
|
|
78
|
-
* client.events.addClans(['#2PP', '']);
|
|
90
|
+
* client.events.addClans(['#2PP', '#8QU8J9LP']);
|
|
79
91
|
*
|
|
80
|
-
* client.events.
|
|
81
|
-
* type: 'CLAN',
|
|
92
|
+
* client.events.setClanEvent({
|
|
82
93
|
* name: 'clanMemberUpdate',
|
|
83
94
|
* filter: (oldClan, newClan) => {
|
|
84
95
|
* return oldClan.memberCount !== newClan.memberCount;
|
|
@@ -87,27 +98,46 @@ class EventManager {
|
|
|
87
98
|
*
|
|
88
99
|
* client.on('clanMemberUpdate', (oldClan, newClan) => {
|
|
89
100
|
* console.log(oldClan.memberCount, newClan.memberCount);
|
|
90
|
-
* })
|
|
101
|
+
* });
|
|
102
|
+
*
|
|
103
|
+
* (async function () {
|
|
104
|
+
* await client.events.init();
|
|
105
|
+
* })();
|
|
91
106
|
* ```
|
|
92
107
|
* @returns
|
|
93
108
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
setClanEvent(event) {
|
|
110
|
+
if (!event.name)
|
|
111
|
+
throw new Error('Event name is required.');
|
|
112
|
+
if (typeof event.filter !== 'function')
|
|
113
|
+
throw new Error('Filter function is required.');
|
|
114
|
+
this._events.clans.push(event);
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Set your own custom war event.
|
|
119
|
+
*
|
|
120
|
+
* In order to emit the custom event, you must have this filter function that returns a boolean.
|
|
121
|
+
*/
|
|
122
|
+
setWarEvent(event) {
|
|
123
|
+
if (!event.name)
|
|
124
|
+
throw new Error('Event name is required.');
|
|
125
|
+
if (typeof event.filter !== 'function')
|
|
126
|
+
throw new Error('Filter function is required.');
|
|
127
|
+
this._events.wars.push(event);
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Set your own custom player event.
|
|
132
|
+
*
|
|
133
|
+
* In order to emit the custom event, you must have this filter function that returns a boolean.
|
|
134
|
+
*/
|
|
135
|
+
setPlayerEvent(event) {
|
|
136
|
+
if (!event.name)
|
|
137
|
+
throw new Error('Event name is required.');
|
|
138
|
+
if (typeof event.filter !== 'function')
|
|
139
|
+
throw new Error('Filter function is required.');
|
|
140
|
+
this._events.players.push(event);
|
|
111
141
|
return this;
|
|
112
142
|
}
|
|
113
143
|
async maintenanceHandler() {
|
|
@@ -116,7 +146,7 @@ class EventManager {
|
|
|
116
146
|
const res = await this.client.rest.getClans({ maxMembers: Math.floor(Math.random() * 40) + 10, limit: 1 });
|
|
117
147
|
if (res.status === 200 && this._inMaintenance) {
|
|
118
148
|
this._inMaintenance = Boolean(false);
|
|
119
|
-
const duration =
|
|
149
|
+
const duration = Date.now() - this._maintenanceStartTime.getTime();
|
|
120
150
|
this._maintenanceStartTime = null;
|
|
121
151
|
this.client.emit(Constants_1.EVENTS.MAINTENANCE_END, duration);
|
|
122
152
|
}
|
|
@@ -153,7 +183,7 @@ class EventManager {
|
|
|
153
183
|
for (const tag of this._playerTags)
|
|
154
184
|
await this.runPlayerUpdate(tag);
|
|
155
185
|
this.client.emit(Constants_1.EVENTS.PLAYER_LOOP_END);
|
|
156
|
-
setTimeout(this.playerUpdateHandler.bind(this),
|
|
186
|
+
setTimeout(this.playerUpdateHandler.bind(this), 10000);
|
|
157
187
|
}
|
|
158
188
|
async warUpdateHandler() {
|
|
159
189
|
this.client.emit(Constants_1.EVENTS.WAR_LOOP_START);
|
|
@@ -171,9 +201,9 @@ class EventManager {
|
|
|
171
201
|
const cached = this._clans.get(clan.tag);
|
|
172
202
|
if (!cached)
|
|
173
203
|
return this._clans.set(clan.tag, clan);
|
|
174
|
-
for (const { name,
|
|
204
|
+
for (const { name, filter } of this._events.clans) {
|
|
175
205
|
try {
|
|
176
|
-
if (!
|
|
206
|
+
if (!filter(cached, clan))
|
|
177
207
|
continue;
|
|
178
208
|
this.client.emit(name, cached, clan);
|
|
179
209
|
}
|
|
@@ -192,9 +222,9 @@ class EventManager {
|
|
|
192
222
|
const cached = this._players.get(player.tag);
|
|
193
223
|
if (!cached)
|
|
194
224
|
return this._players.set(player.tag, player);
|
|
195
|
-
for (const { name,
|
|
225
|
+
for (const { name, filter } of this._events.players) {
|
|
196
226
|
try {
|
|
197
|
-
if (!
|
|
227
|
+
if (!filter(cached, player))
|
|
198
228
|
continue;
|
|
199
229
|
this.client.emit(name, cached, player);
|
|
200
230
|
}
|
|
@@ -211,14 +241,14 @@ class EventManager {
|
|
|
211
241
|
const clanWars = await this.client._getClanWars(tag).catch(() => null);
|
|
212
242
|
if (!clanWars?.length)
|
|
213
243
|
return null;
|
|
214
|
-
clanWars.forEach((war,
|
|
215
|
-
const key =
|
|
244
|
+
clanWars.forEach(async (war, index) => {
|
|
245
|
+
const key = `${tag}:${index}`;
|
|
216
246
|
const cached = this._wars.get(key);
|
|
217
247
|
if (!cached)
|
|
218
248
|
return this._wars.set(key, war);
|
|
219
|
-
for (const { name,
|
|
249
|
+
for (const { name, filter } of this._events.wars) {
|
|
220
250
|
try {
|
|
221
|
-
if (!
|
|
251
|
+
if (!filter(cached, war))
|
|
222
252
|
continue;
|
|
223
253
|
this.client.emit(name, cached, war);
|
|
224
254
|
}
|
|
@@ -226,6 +256,22 @@ class EventManager {
|
|
|
226
256
|
this.client.emit(Constants_1.EVENTS.ERROR, error);
|
|
227
257
|
}
|
|
228
258
|
}
|
|
259
|
+
// check for war end
|
|
260
|
+
if (index === 1 && cached.warTag !== war.warTag) {
|
|
261
|
+
const data = await this.client.getLeagueWar({ clanTag: tag, round: 'PREVIOUS_ROUND' }).catch(() => null);
|
|
262
|
+
if (data && data.warTag === cached.warTag) {
|
|
263
|
+
for (const { name, filter } of this._events.wars) {
|
|
264
|
+
try {
|
|
265
|
+
if (!filter(cached, data))
|
|
266
|
+
continue;
|
|
267
|
+
this.client.emit(name, cached, data);
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
this.client.emit(Constants_1.EVENTS.ERROR, error);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
229
275
|
return this._wars.set(key, war);
|
|
230
276
|
});
|
|
231
277
|
}
|
package/dist/rest/HTTPError.d.ts
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
/** Represents an HTTP Error. */
|
|
2
2
|
export declare class HTTPError extends Error {
|
|
3
|
+
/** The message of this error. */
|
|
4
|
+
message: string;
|
|
5
|
+
/** The HTTP method of this request. */
|
|
3
6
|
method: string;
|
|
7
|
+
/** The reason of this error. */
|
|
4
8
|
reason: string;
|
|
9
|
+
/** The HTTP status code of this request. */
|
|
5
10
|
status: number;
|
|
11
|
+
/** The path of this request. */
|
|
6
12
|
path: string;
|
|
7
|
-
|
|
13
|
+
/** Maximum number of milliseconds the results can be cached. */
|
|
14
|
+
maxAge: number;
|
|
15
|
+
constructor(error: any, status: number, path: string, maxAge: number, method?: string);
|
|
8
16
|
}
|
|
17
|
+
export declare const NotInWarError: {
|
|
18
|
+
message: string;
|
|
19
|
+
reason: string;
|
|
20
|
+
};
|
|
21
|
+
export declare const PrivateWarLogError: {
|
|
22
|
+
message: string;
|
|
23
|
+
reason: string;
|
|
24
|
+
};
|
package/dist/rest/HTTPError.js
CHANGED
|
@@ -1,23 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HTTPError = void 0;
|
|
3
|
+
exports.PrivateWarLogError = exports.NotInWarError = exports.HTTPError = void 0;
|
|
4
4
|
const messages = {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
500: 'Unknown error happened when handling the request.',
|
|
6
|
+
504: 'The user aborted this request.',
|
|
7
|
+
404: 'Requested resource was not found.',
|
|
8
|
+
400: 'Client provided incorrect parameters for the request.',
|
|
9
|
+
503: 'Service is temporarily unavailable because of maintenance.',
|
|
10
|
+
429: 'Request was throttled, because amount of requests was above the threshold defined for the used API token.',
|
|
11
|
+
403: 'Access denied, either because of missing/incorrect credentials or used API token does not grant access to the requested resource.'
|
|
7
12
|
};
|
|
8
13
|
const reasons = {
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
503: 'serviceUnavailable',
|
|
15
|
+
429: 'tooManyRequests',
|
|
16
|
+
400: 'badRequest',
|
|
17
|
+
403: 'forbidden',
|
|
18
|
+
500: 'unknownError',
|
|
19
|
+
404: 'notFound',
|
|
20
|
+
504: 'requestAborted'
|
|
11
21
|
};
|
|
12
22
|
/** Represents an HTTP Error. */
|
|
13
23
|
class HTTPError extends Error {
|
|
14
|
-
constructor(error, status, path, method
|
|
24
|
+
constructor(error, status, path, maxAge, method) {
|
|
15
25
|
super();
|
|
16
26
|
this.message = error?.message ?? messages[status];
|
|
17
27
|
this.reason = error?.reason ?? reasons[status];
|
|
18
28
|
this.path = path;
|
|
19
|
-
this.method = method;
|
|
29
|
+
this.method = method ?? 'GET';
|
|
20
30
|
this.status = status;
|
|
31
|
+
this.maxAge = maxAge;
|
|
21
32
|
}
|
|
22
33
|
}
|
|
23
34
|
exports.HTTPError = HTTPError;
|
|
35
|
+
exports.NotInWarError = {
|
|
36
|
+
message: 'Clan is not in war at this moment.',
|
|
37
|
+
reason: 'notInWar'
|
|
38
|
+
};
|
|
39
|
+
exports.PrivateWarLogError = {
|
|
40
|
+
message: 'Access denied, clan war log is private.',
|
|
41
|
+
reason: 'privateWarLog'
|
|
42
|
+
};
|
|
@@ -2,126 +2,175 @@ import { RequestHandler, SearchOptions, ClanSearchOptions, ClientOptions, Overri
|
|
|
2
2
|
import { APIClan, APIClanList, APIClanMemberList, APIClanRankingList, APIClanVersusRankingList, APIClanWar, APIClanWarLeagueGroup, APIClanWarLog, APIGoldPassSeason, APILabelList, APILeague, APILeagueList, APILeagueSeasonList, APILocation, APILocationList, APIPlayer, APIPlayerRankingList, APIPlayerSeasonRankingList, APIPlayerVersusRankingList, APIVerifyToken, APIWarLeague, APIWarLeagueList } from '../types';
|
|
3
3
|
/** Represents a REST Manager of the client. */
|
|
4
4
|
export declare class RESTManager {
|
|
5
|
+
/** Request Handler for the RESTManager. */
|
|
5
6
|
readonly handler: RequestHandler;
|
|
6
7
|
constructor(options?: ClientOptions);
|
|
8
|
+
/** Search all clans by name and/or filtering the results using various criteria. */
|
|
7
9
|
getClans(options: ClanSearchOptions): Promise<{
|
|
8
10
|
data: APIClanList;
|
|
9
11
|
maxAge: number;
|
|
10
12
|
status: number;
|
|
13
|
+
path: string;
|
|
11
14
|
}>;
|
|
15
|
+
/** Get information about a clan. */
|
|
12
16
|
getClan(clanTag: string, options?: OverrideOptions): Promise<{
|
|
13
17
|
data: APIClan;
|
|
14
18
|
maxAge: number;
|
|
15
19
|
status: number;
|
|
20
|
+
path: string;
|
|
16
21
|
}>;
|
|
22
|
+
/** Get list of clan members. */
|
|
17
23
|
getClanMembers(clanTag: string, options?: SearchOptions): Promise<{
|
|
18
24
|
data: APIClanMemberList;
|
|
19
25
|
maxAge: number;
|
|
20
26
|
status: number;
|
|
27
|
+
path: string;
|
|
21
28
|
}>;
|
|
29
|
+
/** Get clan war log. */
|
|
22
30
|
getClanWarLog(clanTag: string, options?: SearchOptions): Promise<{
|
|
23
31
|
data: APIClanWarLog;
|
|
24
32
|
maxAge: number;
|
|
25
33
|
status: number;
|
|
34
|
+
path: string;
|
|
26
35
|
}>;
|
|
36
|
+
/** Get info about currently running war in the clan. */
|
|
27
37
|
getCurrentWar(clanTag: string, options?: OverrideOptions): Promise<{
|
|
28
38
|
data: APIClanWar;
|
|
29
39
|
maxAge: number;
|
|
30
40
|
status: number;
|
|
41
|
+
path: string;
|
|
31
42
|
}>;
|
|
43
|
+
/** Get information about clan war league. */
|
|
32
44
|
getClanWarLeagueGroup(clanTag: string, options?: OverrideOptions): Promise<{
|
|
33
45
|
data: APIClanWarLeagueGroup;
|
|
34
46
|
maxAge: number;
|
|
35
47
|
status: number;
|
|
48
|
+
path: string;
|
|
36
49
|
}>;
|
|
50
|
+
/** Get info about a CWL round by WarTag. */
|
|
37
51
|
getClanWarLeagueRound(warTag: string, options?: OverrideOptions): Promise<{
|
|
38
52
|
data: APIClanWar;
|
|
39
53
|
maxAge: number;
|
|
40
54
|
status: number;
|
|
55
|
+
path: string;
|
|
41
56
|
}>;
|
|
57
|
+
/** Get information about a player by tag. */
|
|
42
58
|
getPlayer(playerTag: string, options?: OverrideOptions): Promise<{
|
|
43
59
|
data: APIPlayer;
|
|
44
60
|
maxAge: number;
|
|
45
61
|
status: number;
|
|
62
|
+
path: string;
|
|
46
63
|
}>;
|
|
47
|
-
|
|
64
|
+
/** Verify Player API token that can be found from the Game settings. */
|
|
65
|
+
verifyPlayerToken(playerTag: string, token: string, options?: OverrideOptions): Promise<{
|
|
48
66
|
data: APIVerifyToken;
|
|
49
67
|
maxAge: number;
|
|
50
68
|
status: number;
|
|
69
|
+
path: string;
|
|
51
70
|
}>;
|
|
71
|
+
/** Get list of Leagues. */
|
|
52
72
|
getLeagues(options?: SearchOptions): Promise<{
|
|
53
73
|
data: APILeagueList;
|
|
54
74
|
maxAge: number;
|
|
55
75
|
status: number;
|
|
76
|
+
path: string;
|
|
56
77
|
}>;
|
|
78
|
+
/** Get a League info. */
|
|
57
79
|
getLeague(leagueId: string | number, options?: OverrideOptions): Promise<{
|
|
58
80
|
data: APILeague;
|
|
59
81
|
maxAge: number;
|
|
60
82
|
status: number;
|
|
83
|
+
path: string;
|
|
61
84
|
}>;
|
|
85
|
+
/** Get Legend League season Ids. */
|
|
62
86
|
getLeagueSeasons(leagueId: number, options?: SearchOptions): Promise<{
|
|
63
87
|
data: APILeagueSeasonList;
|
|
64
88
|
maxAge: number;
|
|
65
89
|
status: number;
|
|
90
|
+
path: string;
|
|
66
91
|
}>;
|
|
92
|
+
/** Get Legend League season rankings by season Id. */
|
|
67
93
|
getSeasonRankings(leagueId: number, seasonId: string, options?: SearchOptions): Promise<{
|
|
68
94
|
data: APIPlayerSeasonRankingList;
|
|
69
95
|
maxAge: number;
|
|
70
96
|
status: number;
|
|
97
|
+
path: string;
|
|
71
98
|
}>;
|
|
99
|
+
/** Get list of Clan War Leagues. */
|
|
72
100
|
getWarLeagues(options?: SearchOptions): Promise<{
|
|
73
101
|
data: APIWarLeagueList;
|
|
74
102
|
maxAge: number;
|
|
75
103
|
status: number;
|
|
104
|
+
path: string;
|
|
76
105
|
}>;
|
|
106
|
+
/** Get info about a Clan War League. */
|
|
77
107
|
getWarLeague(leagueId: number, options?: OverrideOptions): Promise<{
|
|
78
108
|
data: APIWarLeague;
|
|
79
109
|
maxAge: number;
|
|
80
110
|
status: number;
|
|
111
|
+
path: string;
|
|
81
112
|
}>;
|
|
113
|
+
/** Get list of Locations. */
|
|
82
114
|
getLocations(options?: SearchOptions): Promise<{
|
|
83
115
|
data: APILocationList;
|
|
84
116
|
maxAge: number;
|
|
85
117
|
status: number;
|
|
118
|
+
path: string;
|
|
86
119
|
}>;
|
|
120
|
+
/** Get info about a Location. */
|
|
87
121
|
getLocation(locationId: number, options?: OverrideOptions): Promise<{
|
|
88
122
|
data: APILocation;
|
|
89
123
|
maxAge: number;
|
|
90
124
|
status: number;
|
|
125
|
+
path: string;
|
|
91
126
|
}>;
|
|
127
|
+
/** Get clan rankings for a specific location. */
|
|
92
128
|
getClanRanks(locationId: number | string, options?: SearchOptions): Promise<{
|
|
93
129
|
data: APIClanRankingList;
|
|
94
130
|
maxAge: number;
|
|
95
131
|
status: number;
|
|
132
|
+
path: string;
|
|
96
133
|
}>;
|
|
134
|
+
/** Get player rankings for a specific location. */
|
|
97
135
|
getPlayerRanks(locationId: number | string, options?: SearchOptions): Promise<{
|
|
98
136
|
data: APIPlayerRankingList;
|
|
99
137
|
maxAge: number;
|
|
100
138
|
status: number;
|
|
139
|
+
path: string;
|
|
101
140
|
}>;
|
|
141
|
+
/** Get clan versus rankings for a specific location. */
|
|
102
142
|
getVersusClanRanks(locationId: number | string, options?: SearchOptions): Promise<{
|
|
103
143
|
data: APIClanVersusRankingList;
|
|
104
144
|
maxAge: number;
|
|
105
145
|
status: number;
|
|
146
|
+
path: string;
|
|
106
147
|
}>;
|
|
148
|
+
/** Get player versus rankings for a specific location. */
|
|
107
149
|
getVersusPlayerRanks(locationId: number | string, options?: SearchOptions): Promise<{
|
|
108
150
|
data: APIPlayerVersusRankingList;
|
|
109
151
|
maxAge: number;
|
|
110
152
|
status: number;
|
|
153
|
+
path: string;
|
|
111
154
|
}>;
|
|
155
|
+
/** Get list of clan labels. */
|
|
112
156
|
getClanLabels(options?: SearchOptions): Promise<{
|
|
113
157
|
data: APILabelList;
|
|
114
158
|
maxAge: number;
|
|
115
159
|
status: number;
|
|
160
|
+
path: string;
|
|
116
161
|
}>;
|
|
162
|
+
/** Get list of player labels. */
|
|
117
163
|
getPlayerLabels(options?: SearchOptions): Promise<{
|
|
118
164
|
data: APILabelList;
|
|
119
165
|
maxAge: number;
|
|
120
166
|
status: number;
|
|
167
|
+
path: string;
|
|
121
168
|
}>;
|
|
169
|
+
/** Get info about gold pass season. */
|
|
122
170
|
getGoldPassSeason(options?: OverrideOptions): Promise<{
|
|
123
171
|
data: APIGoldPassSeason;
|
|
124
172
|
maxAge: number;
|
|
125
173
|
status: number;
|
|
174
|
+
path: string;
|
|
126
175
|
}>;
|
|
127
176
|
}
|
package/dist/rest/RESTManager.js
CHANGED
|
@@ -8,90 +8,114 @@ class RESTManager {
|
|
|
8
8
|
constructor(options) {
|
|
9
9
|
this.handler = new RequestHandler_1.RequestHandler(options);
|
|
10
10
|
}
|
|
11
|
+
/** Search all clans by name and/or filtering the results using various criteria. */
|
|
11
12
|
getClans(options) {
|
|
12
13
|
const query = Util_1.Util.queryString(options);
|
|
13
14
|
return this.handler.request(`/clans?${query}`);
|
|
14
15
|
}
|
|
16
|
+
/** Get information about a clan. */
|
|
15
17
|
getClan(clanTag, options) {
|
|
16
18
|
return this.handler.request(`/clans/${Util_1.Util.encodeTag(clanTag)}`, options);
|
|
17
19
|
}
|
|
20
|
+
/** Get list of clan members. */
|
|
18
21
|
getClanMembers(clanTag, options) {
|
|
19
22
|
const query = Util_1.Util.queryString(options);
|
|
20
23
|
return this.handler.request(`/clans/${Util_1.Util.encodeTag(clanTag)}/members?${query}`, options);
|
|
21
24
|
}
|
|
25
|
+
/** Get clan war log. */
|
|
22
26
|
getClanWarLog(clanTag, options) {
|
|
23
27
|
const query = Util_1.Util.queryString(options);
|
|
24
28
|
return this.handler.request(`/clans/${Util_1.Util.encodeTag(clanTag)}/warlog?${query}`, options);
|
|
25
29
|
}
|
|
30
|
+
/** Get info about currently running war in the clan. */
|
|
26
31
|
getCurrentWar(clanTag, options) {
|
|
27
32
|
return this.handler.request(`/clans/${Util_1.Util.encodeTag(clanTag)}/currentwar`, options);
|
|
28
33
|
}
|
|
34
|
+
/** Get information about clan war league. */
|
|
29
35
|
getClanWarLeagueGroup(clanTag, options) {
|
|
30
36
|
return this.handler.request(`/clans/${Util_1.Util.encodeTag(clanTag)}/currentwar/leaguegroup`, options);
|
|
31
37
|
}
|
|
38
|
+
/** Get info about a CWL round by WarTag. */
|
|
32
39
|
getClanWarLeagueRound(warTag, options) {
|
|
33
40
|
return this.handler.request(`/clanwarleagues/wars/${Util_1.Util.encodeTag(warTag)}`, options);
|
|
34
41
|
}
|
|
42
|
+
/** Get information about a player by tag. */
|
|
35
43
|
getPlayer(playerTag, options) {
|
|
36
44
|
return this.handler.request(`/players/${Util_1.Util.encodeTag(playerTag)}`, options);
|
|
37
45
|
}
|
|
38
|
-
|
|
46
|
+
/** Verify Player API token that can be found from the Game settings. */
|
|
47
|
+
verifyPlayerToken(playerTag, token, options) {
|
|
39
48
|
const opts = { method: 'POST', body: JSON.stringify({ token }), ...options };
|
|
40
49
|
return this.handler.request(`/players/${Util_1.Util.encodeTag(playerTag)}/verifytoken`, opts);
|
|
41
50
|
}
|
|
51
|
+
/** Get list of Leagues. */
|
|
42
52
|
getLeagues(options) {
|
|
43
53
|
const query = Util_1.Util.queryString(options);
|
|
44
54
|
return this.handler.request(`/leagues?${query}`, options);
|
|
45
55
|
}
|
|
56
|
+
/** Get a League info. */
|
|
46
57
|
getLeague(leagueId, options) {
|
|
47
58
|
return this.handler.request(`/leagues/${leagueId}`, options);
|
|
48
59
|
}
|
|
60
|
+
/** Get Legend League season Ids. */
|
|
49
61
|
getLeagueSeasons(leagueId, options) {
|
|
50
62
|
const query = Util_1.Util.queryString(options);
|
|
51
63
|
return this.handler.request(`/leagues/${leagueId}/seasons?${query}`, options);
|
|
52
64
|
}
|
|
65
|
+
/** Get Legend League season rankings by season Id. */
|
|
53
66
|
getSeasonRankings(leagueId, seasonId, options) {
|
|
54
67
|
const query = Util_1.Util.queryString(options);
|
|
55
68
|
return this.handler.request(`/leagues/${leagueId}/seasons/${seasonId}?${query}`, options);
|
|
56
69
|
}
|
|
70
|
+
/** Get list of Clan War Leagues. */
|
|
57
71
|
getWarLeagues(options) {
|
|
58
72
|
const query = Util_1.Util.queryString(options);
|
|
59
73
|
return this.handler.request(`/warleagues?${query}`, options);
|
|
60
74
|
}
|
|
75
|
+
/** Get info about a Clan War League. */
|
|
61
76
|
getWarLeague(leagueId, options) {
|
|
62
77
|
return this.handler.request(`/warleagues/${leagueId}`, options);
|
|
63
78
|
}
|
|
79
|
+
/** Get list of Locations. */
|
|
64
80
|
getLocations(options) {
|
|
65
81
|
const query = Util_1.Util.queryString(options);
|
|
66
82
|
return this.handler.request(`/locations?${query}`, options);
|
|
67
83
|
}
|
|
84
|
+
/** Get info about a Location. */
|
|
68
85
|
getLocation(locationId, options) {
|
|
69
86
|
return this.handler.request(`/locations/${locationId}`, options);
|
|
70
87
|
}
|
|
88
|
+
/** Get clan rankings for a specific location. */
|
|
71
89
|
getClanRanks(locationId, options) {
|
|
72
90
|
const query = Util_1.Util.queryString(options);
|
|
73
91
|
return this.handler.request(`/locations/${locationId}/rankings/clans?${query}`, options);
|
|
74
92
|
}
|
|
93
|
+
/** Get player rankings for a specific location. */
|
|
75
94
|
getPlayerRanks(locationId, options) {
|
|
76
95
|
const query = Util_1.Util.queryString(options);
|
|
77
96
|
return this.handler.request(`/locations/${locationId}/rankings/players?${query}`, options);
|
|
78
97
|
}
|
|
98
|
+
/** Get clan versus rankings for a specific location. */
|
|
79
99
|
getVersusClanRanks(locationId, options) {
|
|
80
100
|
const query = Util_1.Util.queryString(options);
|
|
81
101
|
return this.handler.request(`/locations/${locationId}/rankings/clans-versus?${query}`, options);
|
|
82
102
|
}
|
|
103
|
+
/** Get player versus rankings for a specific location. */
|
|
83
104
|
getVersusPlayerRanks(locationId, options) {
|
|
84
105
|
const query = Util_1.Util.queryString(options);
|
|
85
106
|
return this.handler.request(`/locations/${locationId}/rankings/players-versus?${query}`, options);
|
|
86
107
|
}
|
|
108
|
+
/** Get list of clan labels. */
|
|
87
109
|
getClanLabels(options) {
|
|
88
110
|
const query = Util_1.Util.queryString(options);
|
|
89
111
|
return this.handler.request(`/labels/clans?${query}`, options);
|
|
90
112
|
}
|
|
113
|
+
/** Get list of player labels. */
|
|
91
114
|
getPlayerLabels(options) {
|
|
92
115
|
const query = Util_1.Util.queryString(options);
|
|
93
116
|
return this.handler.request(`/labels/players?${query}`, options);
|
|
94
117
|
}
|
|
118
|
+
/** Get info about gold pass season. */
|
|
95
119
|
getGoldPassSeason(options) {
|
|
96
120
|
return this.handler.request('/goldpass/seasons/current', options);
|
|
97
121
|
}
|