refactor: replace deprecated endpoints
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

This commit is contained in:
Dawid Wysokiński 2023-05-07 08:03:51 +02:00
parent c29f987caa
commit b03bae4cd9
Signed by: Kichiyaki
GPG Key ID: B5445E357FB8B892
4 changed files with 16 additions and 16 deletions

View File

@ -1,7 +1,7 @@
const preambles = { const preambles = {
'extended-player-profile': `// ==UserScript== 'extended-player-profile': `// ==UserScript==
// @name Extended player profile // @name Extended player profile
// @version 1.1.2 // @version 1.1.3
// @description Adds additional info and actions on a player overview. // @description Adds additional info and actions on a player overview.
// @author Dawid Wysokiński - Kichiyaki - contact@dwysokinski.me // @author Dawid Wysokiński - Kichiyaki - contact@dwysokinski.me
// @match https://*/game.php?*screen=info_player* // @match https://*/game.php?*screen=info_player*
@ -37,7 +37,7 @@ const preambles = {
// ==/UserScript==`, // ==/UserScript==`,
'extended-tribe-profile': `// ==UserScript== 'extended-tribe-profile': `// ==UserScript==
// @name Extended tribe profile // @name Extended tribe profile
// @version 1.0.0 // @version 1.0.1
// @description Adds additional info and actions on a tribe overview. // @description Adds additional info and actions on a tribe overview.
// @author Dawid Wysokiński - Kichiyaki - contact@dwysokinski.me // @author Dawid Wysokiński - Kichiyaki - contact@dwysokinski.me
// @match https://*/game.php?*screen=info_ally* // @match https://*/game.php?*screen=info_ally*

View File

@ -71,8 +71,8 @@ class TWHelpConnector {
} }
async latestSnapshot() { async latestSnapshot() {
const history = await this.playerHistory(1, 1); const snapshot = await this.playerSnapshots(1, 1);
return history.data.length > 0 ? history.data[0] : null; return snapshot.data.length > 0 ? snapshot.data[0] : null;
} }
playerTribeChanges(page: number, limit: number) { playerTribeChanges(page: number, limit: number) {
@ -91,8 +91,8 @@ class TWHelpConnector {
}); });
} }
playerHistory(page: number, limit: number) { playerSnapshots(page: number, limit: number) {
return this.client.playerHistory(this.version, this.server, this.id, { return this.client.playerSnapshots(this.version, this.server, this.id, {
offset: (page - 1) * limit, offset: (page - 1) * limit,
limit, limit,
sort: ['date:desc'], sort: ['date:desc'],
@ -511,7 +511,7 @@ class UI {
], ],
30, 30,
(page: number, limit: number) => { (page: number, limit: number) => {
return this.twhelpConnector.playerHistory(page, limit); return this.twhelpConnector.playerSnapshots(page, limit);
} }
).render(); ).render();
} }

View File

@ -60,12 +60,12 @@ class TWHelpConnector {
} }
async latestSnapshot() { async latestSnapshot() {
const history = await this.tribeHistory(1, 1); const snapshot = await this.tribeSnapshots(1, 1);
return history.data.length > 0 ? history.data[0] : null; return snapshot.data.length > 0 ? snapshot.data[0] : null;
} }
tribeHistory(page: number, limit: number) { tribeSnapshots(page: number, limit: number) {
return this.client.tribeHistory(this.version, this.server, this.id, { return this.client.tribeSnapshots(this.version, this.server, this.id, {
offset: (page - 1) * limit, offset: (page - 1) * limit,
limit, limit,
sort: ['date:desc'], sort: ['date:desc'],
@ -376,7 +376,7 @@ class UI {
], ],
30, 30,
(page: number, limit: number) => { (page: number, limit: number) => {
return this.twhelpConnector.tribeHistory(page, limit); return this.twhelpConnector.tribeSnapshots(page, limit);
} }
).render(); ).render();
} }

View File

@ -237,7 +237,7 @@ export class TWHelpClient {
return resp.data.data; return resp.data.data;
} }
public async tribeHistory( public async tribeSnapshots(
version: string, version: string,
server: string, server: string,
id: number, id: number,
@ -245,7 +245,7 @@ export class TWHelpClient {
): Promise<ListResult<TribeSnapshot>> { ): Promise<ListResult<TribeSnapshot>> {
const queryString = queryParams ? this.buildQueryString(queryParams) : ''; const queryString = queryParams ? this.buildQueryString(queryParams) : '';
const resp = await this.client.get( const resp = await this.client.get(
`/api/v1/versions/${version}/servers/${server}/tribes/${id}/history?${queryString}` `/api/v1/versions/${version}/servers/${server}/tribes/${id}/snapshots?${queryString}`
); );
return { return {
data: resp.data.data, data: resp.data.data,
@ -344,7 +344,7 @@ export class TWHelpClient {
}; };
} }
public async playerHistory( public async playerSnapshots(
version: string, version: string,
server: string, server: string,
id: number, id: number,
@ -352,7 +352,7 @@ export class TWHelpClient {
): Promise<ListResult<PlayerSnapshot>> { ): Promise<ListResult<PlayerSnapshot>> {
const queryString = queryParams ? this.buildQueryString(queryParams) : ''; const queryString = queryParams ? this.buildQueryString(queryParams) : '';
const resp = await this.client.get( const resp = await this.client.get(
`/api/v1/versions/${version}/servers/${server}/players/${id}/history?${queryString}` `/api/v1/versions/${version}/servers/${server}/players/${id}/snapshots?${queryString}`
); );
return { return {
data: resp.data.data, data: resp.data.data,