clashofclans.js 2.4.0 → 2.5.1-dev.2ab26dd

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 CHANGED
@@ -2,18 +2,31 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## 2.5.1 (2022-01-11)
6
+
7
+ ### Bug Fixes
8
+
9
+ - Typings for `ClanWarLeagueGroup#state` property. ([#94](https://github.com/clashperk/clashofclans.js/pull/94))
10
+
11
+ ## 2.5.0 (2021-12-30)
12
+
13
+ ### Bug Fixes
14
+
15
+ - Fix caching issue with unnecessary/invalid query params. ([#91](https://github.com/clashperk/clashofclans.js/pull/91))
16
+ - Added necessary methods to `RESTManager` class. ([#92](https://github.com/clashperk/clashofclans.js/pull/92))
17
+
5
18
  ## 2.4.0 (2021-12-28)
6
19
 
7
20
  ### Features
8
21
 
9
- - `ClanWar.getClanWarLeague`, `ClanWar.isCWL` and `ClanWar.isFriendly` are now available. ([#87](https://github.com/clashperk/clashofclans.js/pull/87))
10
- - `RESTOptions.rejectIfNotValid` added to perform `res.ok` operations over `RESTManager` class. ([#87](https://github.com/clashperk/clashofclans.js/pull/87))
11
- - `Icon.fileName` and `Icon.sizes` are now available in `Icon` class. ([#87](https://github.com/clashperk/clashofclans.js/pull/87))
12
- - `Badge.fileName` and `Badge.sizes` are now available in `Badge` class. ([#87](https://github.com/clashperk/clashofclans.js/pull/87))
22
+ - `ClanWar#getClanWarLeagueGroup`, `ClanWar#isCWL` and `ClanWar#isFriendly` are now available. ([#87](https://github.com/clashperk/clashofclans.js/pull/87))
23
+ - `RESTOptions#rejectIfNotValid` added to perform `res.ok` operations over `RESTManager` methods. [Know more?](https://clashofclans.js.org/guide/access-raw-data#easy-access) ([#87](https://github.com/clashperk/clashofclans.js/pull/87))
24
+ - `Icon#fileName` and `Icon#sizes` are now available in `Icon` class. ([#87](https://github.com/clashperk/clashofclans.js/pull/87))
25
+ - `Badge#fileName` and `Badge#sizes` are now available in `Badge` class. ([#87](https://github.com/clashperk/clashofclans.js/pull/87))
13
26
 
14
27
  ### Deprecations
15
28
 
16
- - `ClanWarMember.previousBestOpponentAttack` has been deprecated. Use `ClanWarAttack.previousBestAttack` instead. ([#87](https://github.com/clashperk/clashofclans.js/pull/87))
29
+ - `ClanWarMember#previousBestOpponentAttack` has been deprecated. Use `ClanWarAttack#previousBestAttack` instead. ([#87](https://github.com/clashperk/clashofclans.js/pull/87))
17
30
 
18
31
  ## 2.3.0 (2021-12-17)
19
32
 
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { ClanSearchOptions, SearchOptions, ClientOptions, InitOptions, OverrideOptions } from '../rest/RequestHandler';
2
+ import { ClanSearchOptions, SearchOptions, ClientOptions, LoginOptions, OverrideOptions } from '../types';
3
3
  import { EVENTS, CWL_ROUNDS } from '../util/Constants';
4
4
  import { RESTManager } from '../rest/RESTManager';
5
5
  import { EventManager } from './EventManager';
@@ -31,7 +31,7 @@ export declare class Client extends EventEmitter {
31
31
  * client.login({ email: 'developer@email.com', password: '***' });
32
32
  * ```
33
33
  */
34
- login(options: InitOptions): Promise<string[]>;
34
+ login(options: LoginOptions): Promise<string[]>;
35
35
  /** Set Clash of Clans API keys. */
36
36
  setKeys(keys: string[]): this;
37
37
  /** Search all clans by name and/or filtering the results using various criteria. */
@@ -1,56 +1,70 @@
1
- import { RequestHandler, SearchOptions, ClanSearchOptions, RESTOptions, OverrideOptions } from './RequestHandler';
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';
1
+ import { RequestHandler } from './RequestHandler';
2
+ import { Util } from '../util/Util';
3
+ import { APIClan, APIClanList, APIClanMemberList, APIClanRankingList, APIClanVersusRankingList, APIClanWar, APIClanWarLeagueGroup, APIClanWarLog, APIGoldPassSeason, APILabelList, APILeague, APILeagueList, APILeagueSeasonList, APILocation, APILocationList, APIPlayer, APIPlayerRankingList, APIPlayerSeasonRankingList, APIPlayerVersusRankingList, APIVerifyToken, APIWarLeague, APIWarLeagueList, SearchOptions, ClanSearchOptions, RESTOptions, OverrideOptions, LoginOptions } from '../types';
3
4
  /** Represents a REST Manager of the client. */
4
5
  export declare class RESTManager {
5
6
  /** Request Handler for the RESTManager. */
6
7
  readonly handler: RequestHandler;
7
8
  constructor(options?: RESTOptions);
9
+ /** Contains various general-purpose utility methods. */
10
+ get util(): typeof Util;
11
+ /**
12
+ * Initialize the client to create keys.
13
+ * @example
14
+ * ```
15
+ * const rest = new RESTManager();
16
+ * rest.login({ email: 'developer@email.com', password: '***' });
17
+ * ```
18
+ */
19
+ login(options: LoginOptions): Promise<string[]>;
20
+ /** Set Clash of Clans API keys. */
21
+ setKeys(keys: string[]): this;
8
22
  /** Search all clans by name and/or filtering the results using various criteria. */
9
- getClans(query: ClanSearchOptions, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIClanList>>;
23
+ getClans(query: ClanSearchOptions, options?: OverrideOptions): Promise<import("../types").Response<APIClanList>>;
10
24
  /** Get info about a clan. */
11
- getClan(clanTag: string, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIClan>>;
25
+ getClan(clanTag: string, options?: OverrideOptions): Promise<import("../types").Response<APIClan>>;
12
26
  /** Get list of clan members. */
13
- getClanMembers(clanTag: string, options?: SearchOptions): Promise<import("./RequestHandler").Response<APIClanMemberList>>;
27
+ getClanMembers(clanTag: string, options?: SearchOptions): Promise<import("../types").Response<APIClanMemberList>>;
14
28
  /** Get clan war log. */
15
- getClanWarLog(clanTag: string, options?: SearchOptions): Promise<import("./RequestHandler").Response<APIClanWarLog>>;
29
+ getClanWarLog(clanTag: string, options?: SearchOptions): Promise<import("../types").Response<APIClanWarLog>>;
16
30
  /** Get info about currently running war in the clan. */
17
- getCurrentWar(clanTag: string, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIClanWar>>;
31
+ getCurrentWar(clanTag: string, options?: OverrideOptions): Promise<import("../types").Response<APIClanWar>>;
18
32
  /** Get info about clan war league. */
19
- getClanWarLeagueGroup(clanTag: string, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIClanWarLeagueGroup>>;
33
+ getClanWarLeagueGroup(clanTag: string, options?: OverrideOptions): Promise<import("../types").Response<APIClanWarLeagueGroup>>;
20
34
  /** Get info about a CWL round by WarTag. */
21
- getClanWarLeagueRound(warTag: string, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIClanWar>>;
35
+ getClanWarLeagueRound(warTag: string, options?: OverrideOptions): Promise<import("../types").Response<APIClanWar>>;
22
36
  /** Get info about a player by tag. */
23
- getPlayer(playerTag: string, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIPlayer>>;
37
+ getPlayer(playerTag: string, options?: OverrideOptions): Promise<import("../types").Response<APIPlayer>>;
24
38
  /** 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>>;
39
+ verifyPlayerToken(playerTag: string, token: string, options?: OverrideOptions): Promise<import("../types").Response<APIVerifyToken>>;
26
40
  /** Get list of Leagues. */
27
- getLeagues(options?: SearchOptions): Promise<import("./RequestHandler").Response<APILeagueList>>;
41
+ getLeagues(options?: SearchOptions): Promise<import("../types").Response<APILeagueList>>;
28
42
  /** Get a League info. */
29
- getLeague(leagueId: string | number, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APILeague>>;
43
+ getLeague(leagueId: string | number, options?: OverrideOptions): Promise<import("../types").Response<APILeague>>;
30
44
  /** Get Legend League season Ids. */
31
- getLeagueSeasons(leagueId: number, options?: SearchOptions): Promise<import("./RequestHandler").Response<APILeagueSeasonList>>;
45
+ getLeagueSeasons(leagueId: number, options?: SearchOptions): Promise<import("../types").Response<APILeagueSeasonList>>;
32
46
  /** Get Legend League season rankings by season Id. */
33
- getSeasonRankings(leagueId: number, seasonId: string, options?: SearchOptions): Promise<import("./RequestHandler").Response<APIPlayerSeasonRankingList>>;
47
+ getSeasonRankings(leagueId: number, seasonId: string, options?: SearchOptions): Promise<import("../types").Response<APIPlayerSeasonRankingList>>;
34
48
  /** Get list of Clan War Leagues. */
35
- getWarLeagues(options?: SearchOptions): Promise<import("./RequestHandler").Response<APIWarLeagueList>>;
49
+ getWarLeagues(options?: SearchOptions): Promise<import("../types").Response<APIWarLeagueList>>;
36
50
  /** Get info about a Clan War League. */
37
- getWarLeague(leagueId: number, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIWarLeague>>;
51
+ getWarLeague(leagueId: number, options?: OverrideOptions): Promise<import("../types").Response<APIWarLeague>>;
38
52
  /** Get list of Locations. */
39
- getLocations(options?: SearchOptions): Promise<import("./RequestHandler").Response<APILocationList>>;
53
+ getLocations(options?: SearchOptions): Promise<import("../types").Response<APILocationList>>;
40
54
  /** Get info about a Location. */
41
- getLocation(locationId: number, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APILocation>>;
55
+ getLocation(locationId: number, options?: OverrideOptions): Promise<import("../types").Response<APILocation>>;
42
56
  /** Get clan rankings for a specific location. */
43
- getClanRanks(locationId: number | string, options?: SearchOptions): Promise<import("./RequestHandler").Response<APIClanRankingList>>;
57
+ getClanRanks(locationId: number | string, options?: SearchOptions): Promise<import("../types").Response<APIClanRankingList>>;
44
58
  /** Get player rankings for a specific location. */
45
- getPlayerRanks(locationId: number | string, options?: SearchOptions): Promise<import("./RequestHandler").Response<APIPlayerRankingList>>;
59
+ getPlayerRanks(locationId: number | string, options?: SearchOptions): Promise<import("../types").Response<APIPlayerRankingList>>;
46
60
  /** Get clan versus rankings for a specific location. */
47
- getVersusClanRanks(locationId: number | string, options?: SearchOptions): Promise<import("./RequestHandler").Response<APIClanVersusRankingList>>;
61
+ getVersusClanRanks(locationId: number | string, options?: SearchOptions): Promise<import("../types").Response<APIClanVersusRankingList>>;
48
62
  /** Get player versus rankings for a specific location. */
49
- getVersusPlayerRanks(locationId: number | string, options?: SearchOptions): Promise<import("./RequestHandler").Response<APIPlayerVersusRankingList>>;
63
+ getVersusPlayerRanks(locationId: number | string, options?: SearchOptions): Promise<import("../types").Response<APIPlayerVersusRankingList>>;
50
64
  /** Get list of clan labels. */
51
- getClanLabels(options?: SearchOptions): Promise<import("./RequestHandler").Response<APILabelList>>;
65
+ getClanLabels(options?: SearchOptions): Promise<import("../types").Response<APILabelList>>;
52
66
  /** Get list of player labels. */
53
- getPlayerLabels(options?: SearchOptions): Promise<import("./RequestHandler").Response<APILabelList>>;
67
+ getPlayerLabels(options?: SearchOptions): Promise<import("../types").Response<APILabelList>>;
54
68
  /** Get info about gold pass season. */
55
- getGoldPassSeason(options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIGoldPassSeason>>;
69
+ getGoldPassSeason(options?: OverrideOptions): Promise<import("../types").Response<APIGoldPassSeason>>;
56
70
  }
@@ -8,9 +8,29 @@ class RESTManager {
8
8
  constructor(options) {
9
9
  this.handler = new RequestHandler_1.RequestHandler(options);
10
10
  }
11
+ /** Contains various general-purpose utility methods. */
12
+ get util() {
13
+ return Util_1.Util;
14
+ }
15
+ /**
16
+ * Initialize the client to create keys.
17
+ * @example
18
+ * ```
19
+ * const rest = new RESTManager();
20
+ * rest.login({ email: 'developer@email.com', password: '***' });
21
+ * ```
22
+ */
23
+ login(options) {
24
+ return this.handler.init(options);
25
+ }
26
+ /** Set Clash of Clans API keys. */
27
+ setKeys(keys) {
28
+ this.handler.setKeys(keys);
29
+ return this;
30
+ }
11
31
  /** Search all clans by name and/or filtering the results using various criteria. */
12
32
  getClans(query, options) {
13
- return this.handler.request(`/clans?${Util_1.Util.queryString(query)}`, options);
33
+ return this.handler.request(`/clans${Util_1.Util.queryString(query)}`, options);
14
34
  }
15
35
  /** Get info about a clan. */
16
36
  getClan(clanTag, options) {
@@ -19,12 +39,12 @@ class RESTManager {
19
39
  /** Get list of clan members. */
20
40
  getClanMembers(clanTag, options) {
21
41
  const query = Util_1.Util.queryString(options);
22
- return this.handler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}/members?${query}`, options);
42
+ return this.handler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}/members${query}`, options);
23
43
  }
24
44
  /** Get clan war log. */
25
45
  getClanWarLog(clanTag, options) {
26
46
  const query = Util_1.Util.queryString(options);
27
- return this.handler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}/warlog?${query}`, options);
47
+ return this.handler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}/warlog${query}`, options);
28
48
  }
29
49
  /** Get info about currently running war in the clan. */
30
50
  getCurrentWar(clanTag, options) {
@@ -50,7 +70,7 @@ class RESTManager {
50
70
  /** Get list of Leagues. */
51
71
  getLeagues(options) {
52
72
  const query = Util_1.Util.queryString(options);
53
- return this.handler.request(`/leagues?${query}`, options);
73
+ return this.handler.request(`/leagues${query}`, options);
54
74
  }
55
75
  /** Get a League info. */
56
76
  getLeague(leagueId, options) {
@@ -59,17 +79,17 @@ class RESTManager {
59
79
  /** Get Legend League season Ids. */
60
80
  getLeagueSeasons(leagueId, options) {
61
81
  const query = Util_1.Util.queryString(options);
62
- return this.handler.request(`/leagues/${leagueId}/seasons?${query}`, options);
82
+ return this.handler.request(`/leagues/${leagueId}/seasons${query}`, options);
63
83
  }
64
84
  /** Get Legend League season rankings by season Id. */
65
85
  getSeasonRankings(leagueId, seasonId, options) {
66
86
  const query = Util_1.Util.queryString(options);
67
- return this.handler.request(`/leagues/${leagueId}/seasons/${seasonId}?${query}`, options);
87
+ return this.handler.request(`/leagues/${leagueId}/seasons/${seasonId}${query}`, options);
68
88
  }
69
89
  /** Get list of Clan War Leagues. */
70
90
  getWarLeagues(options) {
71
91
  const query = Util_1.Util.queryString(options);
72
- return this.handler.request(`/warleagues?${query}`, options);
92
+ return this.handler.request(`/warleagues${query}`, options);
73
93
  }
74
94
  /** Get info about a Clan War League. */
75
95
  getWarLeague(leagueId, options) {
@@ -78,7 +98,7 @@ class RESTManager {
78
98
  /** Get list of Locations. */
79
99
  getLocations(options) {
80
100
  const query = Util_1.Util.queryString(options);
81
- return this.handler.request(`/locations?${query}`, options);
101
+ return this.handler.request(`/locations${query}`, options);
82
102
  }
83
103
  /** Get info about a Location. */
84
104
  getLocation(locationId, options) {
@@ -87,32 +107,32 @@ class RESTManager {
87
107
  /** Get clan rankings for a specific location. */
88
108
  getClanRanks(locationId, options) {
89
109
  const query = Util_1.Util.queryString(options);
90
- return this.handler.request(`/locations/${locationId}/rankings/clans?${query}`, options);
110
+ return this.handler.request(`/locations/${locationId}/rankings/clans${query}`, options);
91
111
  }
92
112
  /** Get player rankings for a specific location. */
93
113
  getPlayerRanks(locationId, options) {
94
114
  const query = Util_1.Util.queryString(options);
95
- return this.handler.request(`/locations/${locationId}/rankings/players?${query}`, options);
115
+ return this.handler.request(`/locations/${locationId}/rankings/players${query}`, options);
96
116
  }
97
117
  /** Get clan versus rankings for a specific location. */
98
118
  getVersusClanRanks(locationId, options) {
99
119
  const query = Util_1.Util.queryString(options);
100
- return this.handler.request(`/locations/${locationId}/rankings/clans-versus?${query}`, options);
120
+ return this.handler.request(`/locations/${locationId}/rankings/clans-versus${query}`, options);
101
121
  }
102
122
  /** Get player versus rankings for a specific location. */
103
123
  getVersusPlayerRanks(locationId, options) {
104
124
  const query = Util_1.Util.queryString(options);
105
- return this.handler.request(`/locations/${locationId}/rankings/players-versus?${query}`, options);
125
+ return this.handler.request(`/locations/${locationId}/rankings/players-versus${query}`, options);
106
126
  }
107
127
  /** Get list of clan labels. */
108
128
  getClanLabels(options) {
109
129
  const query = Util_1.Util.queryString(options);
110
- return this.handler.request(`/labels/clans?${query}`, options);
130
+ return this.handler.request(`/labels/clans${query}`, options);
111
131
  }
112
132
  /** Get list of player labels. */
113
133
  getPlayerLabels(options) {
114
134
  const query = Util_1.Util.queryString(options);
115
- return this.handler.request(`/labels/players?${query}`, options);
135
+ return this.handler.request(`/labels/players${query}`, options);
116
136
  }
117
137
  /** Get info about gold pass season. */
118
138
  getGoldPassSeason(options) {
@@ -1,5 +1,4 @@
1
- import { QueueThrottler, BatchThrottler } from './Throttler';
2
- import Keyv from 'keyv';
1
+ import { RESTOptions, Response, RequestOptions, LoginOptions } from '../types';
3
2
  /** Represents a Request Handler. */
4
3
  export declare class RequestHandler {
5
4
  #private;
@@ -21,7 +20,7 @@ export declare class RequestHandler {
21
20
  setKeys(keys: string[]): this;
22
21
  request<T>(path: string, options?: RequestOptions): Promise<Response<T>>;
23
22
  private exec;
24
- init(options: InitOptions): Promise<string[]>;
23
+ init(options: LoginOptions): Promise<string[]>;
25
24
  private reValidateKeys;
26
25
  private login;
27
26
  private getKeys;
@@ -29,142 +28,3 @@ export declare class RequestHandler {
29
28
  private createKey;
30
29
  private getIp;
31
30
  }
32
- /** Options for a Client. */
33
- export interface ClientOptions {
34
- /** Keys from Clash of Clans API developer site. */
35
- keys?: string[];
36
- /** Base URL of the Clash of Clans API. */
37
- baseURL?: string;
38
- /**
39
- * How many times to retry on 5XX errors.
40
- */
41
- retryLimit?: number;
42
- /**
43
- * Whether enable or disable internal caching.
44
- * @example
45
- * ```ts
46
- * const client = new Client({ cache: true });
47
- * ```
48
- */
49
- cache?: boolean | Keyv;
50
- /** Time to wait before cancelling a REST request, in milliseconds. */
51
- restRequestTimeout?: number;
52
- /**
53
- * Throttler class which handles rate-limit
54
- * @example
55
- * ```ts
56
- * const client = new Client({ throttler: new QueueThrottler(1000 / 10) });
57
- * ```
58
- * @example
59
- * ```ts
60
- * const client = new Client({ throttler: new BatchThrottler(30) });
61
- * ```
62
- */
63
- throttler?: QueueThrottler | BatchThrottler;
64
- }
65
- /** Options for a RESTManager. */
66
- export interface RESTOptions extends ClientOptions {
67
- /** Set this `false` to use `res.ok` property. */
68
- rejectIfNotValid?: boolean;
69
- }
70
- /** Search options for request. */
71
- export interface SearchOptions extends OverrideOptions {
72
- /** Limit the number of items returned in the response. */
73
- limit?: number;
74
- /**
75
- * Return only items that occur after this marker.
76
- * Before marker can be found from the response, inside the 'paging' property.
77
- * Note that only after or before can be specified for a request, not both.
78
- */
79
- after?: string;
80
- /**
81
- * Return only items that occur before this marker.
82
- * Before marker can be found from the response, inside the 'paging' property.
83
- * Note that only after or before can be specified for a request, not both.
84
- */
85
- before?: string;
86
- }
87
- /** Override options for a request. */
88
- export interface OverrideOptions {
89
- /** Whether to cache this response. */
90
- cache?: boolean;
91
- /** Whether to skip the cache check and request the API. */
92
- force?: boolean;
93
- /** How many times to retry on 5XX errors. */
94
- retryLimit?: string;
95
- /** Whether to ignore throttlers. */
96
- ignoreRateLimit?: boolean;
97
- /** Time to wait before cancelling a REST request, in milliseconds. */
98
- restRequestTimeout?: number;
99
- }
100
- export interface RequestOptions extends OverrideOptions {
101
- /** The request body. */
102
- body?: string;
103
- /** The request method. */
104
- method?: string;
105
- }
106
- export interface Response<T> {
107
- /** Whether the response is ok. */
108
- ok: boolean;
109
- /** The response body. */
110
- data: T;
111
- /** Path of the request for this response. */
112
- path: string;
113
- /** HTTP status code of this response. */
114
- status: number;
115
- /** The maxAge of this response. */
116
- maxAge: number;
117
- }
118
- /**
119
- * Clan search options for a request.
120
- *
121
- * ::info
122
- * If name is used as part of search query, it needs to be at least three characters long.
123
- * Name search parameter is interpreted as wild card search, so it may appear anywhere in the clan name.
124
- * :::
125
- */
126
- export interface ClanSearchOptions {
127
- /** Search clans by name. */
128
- name?: string;
129
- /** Filter by minimum number of clan members. */
130
- minMembers?: number;
131
- /** Filter by maximum number of clan members. */
132
- maxMembers?: number;
133
- /** Filter by minimum amount of clan points. */
134
- minClanPoints?: number;
135
- /** Filter by minimum clan level. */
136
- minClanLevel?: number;
137
- /** Filter by clan war frequency. */
138
- warFrequency?: string;
139
- /** Filter by clan location identifier. For list of available locations, refer to getLocations operation. */
140
- locationId?: string;
141
- /** Comma separated list of label IDs to use for filtering results. */
142
- labelIds?: string;
143
- /** Limit the number of items returned in the response. */
144
- limit?: number;
145
- /**
146
- * Return only items that occur after this marker.
147
- * Before marker can be found from the response, inside the 'paging' property.
148
- * Note that only after or before can be specified for a request, not both.
149
- */
150
- after?: string;
151
- /**
152
- * Return only items that occur before this marker.
153
- * Before marker can be found from the response, inside the 'paging' property.
154
- * Note that only after or before can be specified for a request, not both.
155
- */
156
- before?: string;
157
- }
158
- /** Login options for a client. */
159
- export interface InitOptions {
160
- /** Developer site email address. */
161
- email: string;
162
- /** Developer site password. */
163
- password: string;
164
- /** Name of API key(s). */
165
- keyName?: string;
166
- /** Number of allowed API keys. */
167
- keyCount?: number;
168
- /** Description of API key(s). */
169
- keyDescription?: string;
170
- }
@@ -88,8 +88,8 @@ class RequestHandler {
88
88
  if (!res?.ok && this.rejectIfNotValid) {
89
89
  throw new HTTPError_1.HTTPError(data, res?.status ?? 504, path, maxAge, options.method);
90
90
  }
91
- if (this.cached && maxAge > 0 && options.cache !== false) {
92
- await this.cached.set(path, { data, ttl: Date.now() + maxAge, status: res?.status ?? 504 }, maxAge);
91
+ if (this.cached && maxAge > 0 && options.cache !== false && res?.ok) {
92
+ await this.cached.set(path, { data, ttl: Date.now() + maxAge, status: res.status }, maxAge);
93
93
  }
94
94
  return { data, maxAge, status: res?.status ?? 504, path, ok: res?.status === 200 };
95
95
  }
@@ -1,11 +1,10 @@
1
- import { OverrideOptions } from '../rest/RequestHandler';
1
+ import { APIClan, OverrideOptions } from '../types';
2
2
  import { ChatLanguage } from './ChatLanguage';
3
3
  import { ClanMember } from './ClanMember';
4
4
  import { Client } from '../client/Client';
5
5
  import { WarLeague } from './WarLeague';
6
6
  import type { Player } from './Player';
7
7
  import { Location } from './Location';
8
- import { APIClan } from '../types';
9
8
  import { Label } from './Label';
10
9
  import { Badge } from './Badge';
11
10
  /** Represents a Clan. */
@@ -1,6 +1,5 @@
1
- import { OverrideOptions } from '../rest/RequestHandler';
1
+ import { APIClanMember, OverrideOptions } from '../types';
2
2
  import { Client } from '../client/Client';
3
- import { APIClanMember } from '../types';
4
3
  import { League } from './League';
5
4
  export declare class ClanMember {
6
5
  client: Client;
@@ -136,7 +136,7 @@ class ClanWar {
136
136
  // @ts-expect-error
137
137
  this.state = data.state;
138
138
  this.teamSize = data.teamSize;
139
- this.attacksPerMember = data.attacksPerMember ?? extra.warTag ? 1 : 2;
139
+ this.attacksPerMember = data.attacksPerMember ?? (extra.warTag ? 1 : 2);
140
140
  this.preparationStartTime = client.util.formatDate(data.preparationStartTime);
141
141
  this.startTime = client.util.formatDate(data.startTime);
142
142
  this.endTime = client.util.formatDate(data.endTime);
@@ -1,5 +1,4 @@
1
- import { APIClanWarLeagueClan, APIClanWarLeagueClanMember, APIClanWarLeagueGroup, APIClanWarLeagueRound } from '../types';
2
- import { OverrideOptions } from '../rest/RequestHandler';
1
+ import { APIClanWarLeagueClan, APIClanWarLeagueClanMember, APIClanWarLeagueGroup, APIClanWarLeagueRound, OverrideOptions } from '../types';
3
2
  import { Client } from '../client/Client';
4
3
  import { ClanWar } from './ClanWar';
5
4
  import { Player } from './Player';
@@ -43,7 +42,7 @@ export declare class ClanWarLeagueRound {
43
42
  export declare class ClanWarLeagueGroup {
44
43
  private readonly client;
45
44
  /** The CWL group's current war state. */
46
- state: 'preparation' | 'inWar' | 'warEnded';
45
+ state: 'preparation' | 'inWar' | 'ended';
47
46
  /** Season Id of this CWL group. */
48
47
  season: string;
49
48
  /** Returns all participating clans. */
@@ -4,10 +4,8 @@ import { Badge } from './Badge';
4
4
  /**
5
5
  * Represents War Log Clan.
6
6
  *
7
- * :::caution
8
7
  * If this is called via {@link ClanWarLog.opponent}, then {@link WarLogClan.attackCount} and {@link WarLogClan.expEarned} will be `null`.
9
8
  * For CWL entries {@link WarLogClan.name} and {@link WarLogClan.tag} are `null`.
10
- * :::
11
9
  */
12
10
  export declare class WarLogClan {
13
11
  /** The clan's name. This property is `null` CWL entries. */
@@ -6,10 +6,8 @@ const Badge_1 = require("./Badge");
6
6
  /**
7
7
  * Represents War Log Clan.
8
8
  *
9
- * :::caution
10
9
  * If this is called via {@link ClanWarLog.opponent}, then {@link WarLogClan.attackCount} and {@link WarLogClan.expEarned} will be `null`.
11
10
  * For CWL entries {@link WarLogClan.name} and {@link WarLogClan.tag} are `null`.
12
- * :::
13
11
  */
14
12
  class WarLogClan {
15
13
  constructor(data) {
@@ -1,10 +1,9 @@
1
- import { OverrideOptions } from '../rest/RequestHandler';
1
+ import { APIPlayer, OverrideOptions } from '../types';
2
2
  import { LegendStatistics } from './LegendStatistics';
3
3
  import { Achievement } from './Achievement';
4
4
  import { Hero, Spell, Troop } from './Unit';
5
5
  import { PlayerClan } from './PlayerClan';
6
6
  import { Client } from '../client/Client';
7
- import { APIPlayer } from '../types';
8
7
  import { League } from './League';
9
8
  import { Label } from './Label';
10
9
  /** Represents a Clash of Clans Player. */
@@ -1,6 +1,5 @@
1
- import { OverrideOptions } from '../rest/RequestHandler';
1
+ import { OverrideOptions, APIPlayerClan } from '../types';
2
2
  import { Client } from '../client/Client';
3
- import { APIPlayerClan } from '../types';
4
3
  import { Badge } from './Badge';
5
4
  /** Represents a Player's clan. */
6
5
  export declare class PlayerClan {