clashofclans.js 2.0.0-dev.ba3ae68 → 2.0.0

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.
@@ -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} class. */
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
- addClans(...tags) {
35
- for (const tag of tags) {
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
- deleteClans(...tags) {
41
- for (const tag of tags) {
42
- this._warTags.delete(this.client.util.parseTag(tag));
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
- addPlayers(...tags) {
47
- for (const tag of tags) {
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
- deletePlayers(...tags) {
53
- for (const tag of tags) {
54
- this._warTags.delete(this.client.util.parseTag(tag));
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
- addWars(...tags) {
59
- for (const tag of tags) {
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
- deleteWars(...tags) {
65
- for (const tag of tags) {
66
- this._warTags.delete(this.client.util.parseTag(tag));
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
- * @param event.type - `CLAN` | `PLAYER` | `CLAN_WAR`
73
- * @param event.name - Name of the event.
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.setEvent({
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
- setEvent(event) {
95
- switch (event.type) {
96
- case 'CLAN':
97
- // @ts-expect-error
98
- this._events.clans.push(event);
99
- break;
100
- case 'PLAYER':
101
- // @ts-expect-error
102
- this._events.players.push(event);
103
- break;
104
- case 'CLAN_WAR':
105
- // @ts-expect-error
106
- this._events.wars.push(event);
107
- break;
108
- default:
109
- break;
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 = this._maintenanceStartTime.getTime() - Date.now();
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
  }
@@ -146,21 +176,21 @@ class EventManager {
146
176
  for (const tag of this._clanTags)
147
177
  await this.runClanUpdate(tag);
148
178
  this.client.emit(Constants_1.EVENTS.CLAN_LOOP_END);
149
- setTimeout(this.clanUpdateHandler.bind(this), 10000);
179
+ setTimeout(this.clanUpdateHandler.bind(this), 10000).unref();
150
180
  }
151
181
  async playerUpdateHandler() {
152
182
  this.client.emit(Constants_1.EVENTS.PLAYER_LOOP_START);
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), 100000);
186
+ setTimeout(this.playerUpdateHandler.bind(this), 10000).unref();
157
187
  }
158
188
  async warUpdateHandler() {
159
189
  this.client.emit(Constants_1.EVENTS.WAR_LOOP_START);
160
190
  for (const tag of this._warTags)
161
191
  await this.runWarUpdate(tag);
162
192
  this.client.emit(Constants_1.EVENTS.WAR_LOOP_END);
163
- setTimeout(this.warUpdateHandler.bind(this), 10000);
193
+ setTimeout(this.warUpdateHandler.bind(this), 10000).unref();
164
194
  }
165
195
  async runClanUpdate(tag) {
166
196
  if (this._inMaintenance)
@@ -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, fn } of this._events.clans) {
204
+ for (const { name, filter } of this._events.clans) {
175
205
  try {
176
- if (!fn(cached, clan))
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, fn } of this._events.players) {
225
+ for (const { name, filter } of this._events.players) {
196
226
  try {
197
- if (!fn(cached, player))
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, i) => {
215
- const key = `WAR:${i}:${tag}`;
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, fn } of this._events.wars) {
249
+ for (const { name, filter } of this._events.wars) {
220
250
  try {
221
- if (!fn(cached, war))
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
  }
@@ -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
- constructor(error: any, status: number, path: string, method?: string);
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
+ };
@@ -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
- 504: 'The user aborted a request.',
6
- 404: 'Resource was not found.'
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
- 504: 'networkTimeout',
10
- 404: 'notFound'
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 = 'GET') {
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,55 @@ 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);
7
- getClans(options: ClanSearchOptions): Promise<{
8
- data: APIClanList;
9
- maxAge: number;
10
- status: number;
11
- }>;
12
- getClan(clanTag: string, options?: OverrideOptions): Promise<{
13
- data: APIClan;
14
- maxAge: number;
15
- status: number;
16
- }>;
17
- getClanMembers(clanTag: string, options?: SearchOptions): Promise<{
18
- data: APIClanMemberList;
19
- maxAge: number;
20
- status: number;
21
- }>;
22
- getClanWarLog(clanTag: string, options?: SearchOptions): Promise<{
23
- data: APIClanWarLog;
24
- maxAge: number;
25
- status: number;
26
- }>;
27
- getCurrentWar(clanTag: string, options?: OverrideOptions): Promise<{
28
- data: APIClanWar;
29
- maxAge: number;
30
- status: number;
31
- }>;
32
- getClanWarLeagueGroup(clanTag: string, options?: OverrideOptions): Promise<{
33
- data: APIClanWarLeagueGroup;
34
- maxAge: number;
35
- status: number;
36
- }>;
37
- getClanWarLeagueRound(warTag: string, options?: OverrideOptions): Promise<{
38
- data: APIClanWar;
39
- maxAge: number;
40
- status: number;
41
- }>;
42
- getPlayer(playerTag: string, options?: OverrideOptions): Promise<{
43
- data: APIPlayer;
44
- maxAge: number;
45
- status: number;
46
- }>;
47
- postPlayerToken(playerTag: string, token: string, options?: OverrideOptions): Promise<{
48
- data: APIVerifyToken;
49
- maxAge: number;
50
- status: number;
51
- }>;
52
- getLeagues(options?: SearchOptions): Promise<{
53
- data: APILeagueList;
54
- maxAge: number;
55
- status: number;
56
- }>;
57
- getLeague(leagueId: string | number, options?: OverrideOptions): Promise<{
58
- data: APILeague;
59
- maxAge: number;
60
- status: number;
61
- }>;
62
- getLeagueSeasons(leagueId: number, options?: SearchOptions): Promise<{
63
- data: APILeagueSeasonList;
64
- maxAge: number;
65
- status: number;
66
- }>;
67
- getSeasonRankings(leagueId: number, seasonId: string, options?: SearchOptions): Promise<{
68
- data: APIPlayerSeasonRankingList;
69
- maxAge: number;
70
- status: number;
71
- }>;
72
- getWarLeagues(options?: SearchOptions): Promise<{
73
- data: APIWarLeagueList;
74
- maxAge: number;
75
- status: number;
76
- }>;
77
- getWarLeague(leagueId: number, options?: OverrideOptions): Promise<{
78
- data: APIWarLeague;
79
- maxAge: number;
80
- status: number;
81
- }>;
82
- getLocations(options?: SearchOptions): Promise<{
83
- data: APILocationList;
84
- maxAge: number;
85
- status: number;
86
- }>;
87
- getLocation(locationId: number, options?: OverrideOptions): Promise<{
88
- data: APILocation;
89
- maxAge: number;
90
- status: number;
91
- }>;
92
- getClanRanks(locationId: number | string, options?: SearchOptions): Promise<{
93
- data: APIClanRankingList;
94
- maxAge: number;
95
- status: number;
96
- }>;
97
- getPlayerRanks(locationId: number | string, options?: SearchOptions): Promise<{
98
- data: APIPlayerRankingList;
99
- maxAge: number;
100
- status: number;
101
- }>;
102
- getVersusClanRanks(locationId: number | string, options?: SearchOptions): Promise<{
103
- data: APIClanVersusRankingList;
104
- maxAge: number;
105
- status: number;
106
- }>;
107
- getVersusPlayerRanks(locationId: number | string, options?: SearchOptions): Promise<{
108
- data: APIPlayerVersusRankingList;
109
- maxAge: number;
110
- status: number;
111
- }>;
112
- getClanLabels(options?: SearchOptions): Promise<{
113
- data: APILabelList;
114
- maxAge: number;
115
- status: number;
116
- }>;
117
- getPlayerLabels(options?: SearchOptions): Promise<{
118
- data: APILabelList;
119
- maxAge: number;
120
- status: number;
121
- }>;
122
- getGoldPassSeason(options?: OverrideOptions): Promise<{
123
- data: APIGoldPassSeason;
124
- maxAge: number;
125
- status: number;
126
- }>;
8
+ /** Search all clans by name and/or filtering the results using various criteria. */
9
+ getClans(options: ClanSearchOptions): Promise<import("./RequestHandler").Response<APIClanList>>;
10
+ /** Get information about a clan. */
11
+ getClan(clanTag: string, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIClan>>;
12
+ /** Get list of clan members. */
13
+ getClanMembers(clanTag: string, options?: SearchOptions): Promise<import("./RequestHandler").Response<APIClanMemberList>>;
14
+ /** Get clan war log. */
15
+ getClanWarLog(clanTag: string, options?: SearchOptions): Promise<import("./RequestHandler").Response<APIClanWarLog>>;
16
+ /** Get info about currently running war in the clan. */
17
+ getCurrentWar(clanTag: string, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIClanWar>>;
18
+ /** Get information about clan war league. */
19
+ getClanWarLeagueGroup(clanTag: string, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIClanWarLeagueGroup>>;
20
+ /** Get info about a CWL round by WarTag. */
21
+ getClanWarLeagueRound(warTag: string, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIClanWar>>;
22
+ /** Get information about a player by tag. */
23
+ getPlayer(playerTag: string, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIPlayer>>;
24
+ /** Verify Player API token that can be found from the Game settings. */
25
+ verifyPlayerToken(playerTag: string, token: string, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIVerifyToken>>;
26
+ /** Get list of Leagues. */
27
+ getLeagues(options?: SearchOptions): Promise<import("./RequestHandler").Response<APILeagueList>>;
28
+ /** Get a League info. */
29
+ getLeague(leagueId: string | number, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APILeague>>;
30
+ /** Get Legend League season Ids. */
31
+ getLeagueSeasons(leagueId: number, options?: SearchOptions): Promise<import("./RequestHandler").Response<APILeagueSeasonList>>;
32
+ /** Get Legend League season rankings by season Id. */
33
+ getSeasonRankings(leagueId: number, seasonId: string, options?: SearchOptions): Promise<import("./RequestHandler").Response<APIPlayerSeasonRankingList>>;
34
+ /** Get list of Clan War Leagues. */
35
+ getWarLeagues(options?: SearchOptions): Promise<import("./RequestHandler").Response<APIWarLeagueList>>;
36
+ /** Get info about a Clan War League. */
37
+ getWarLeague(leagueId: number, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIWarLeague>>;
38
+ /** Get list of Locations. */
39
+ getLocations(options?: SearchOptions): Promise<import("./RequestHandler").Response<APILocationList>>;
40
+ /** Get info about a Location. */
41
+ getLocation(locationId: number, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APILocation>>;
42
+ /** Get clan rankings for a specific location. */
43
+ getClanRanks(locationId: number | string, options?: SearchOptions): Promise<import("./RequestHandler").Response<APIClanRankingList>>;
44
+ /** Get player rankings for a specific location. */
45
+ getPlayerRanks(locationId: number | string, options?: SearchOptions): Promise<import("./RequestHandler").Response<APIPlayerRankingList>>;
46
+ /** Get clan versus rankings for a specific location. */
47
+ getVersusClanRanks(locationId: number | string, options?: SearchOptions): Promise<import("./RequestHandler").Response<APIClanVersusRankingList>>;
48
+ /** Get player versus rankings for a specific location. */
49
+ getVersusPlayerRanks(locationId: number | string, options?: SearchOptions): Promise<import("./RequestHandler").Response<APIPlayerVersusRankingList>>;
50
+ /** Get list of clan labels. */
51
+ getClanLabels(options?: SearchOptions): Promise<import("./RequestHandler").Response<APILabelList>>;
52
+ /** Get list of player labels. */
53
+ getPlayerLabels(options?: SearchOptions): Promise<import("./RequestHandler").Response<APILabelList>>;
54
+ /** Get info about gold pass season. */
55
+ getGoldPassSeason(options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIGoldPassSeason>>;
127
56
  }
@@ -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
- postPlayerToken(playerTag, token, options) {
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
  }