Skip to content

Commit

Permalink
update api to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
siranweb committed Aug 25, 2024
1 parent 9ded8ae commit 35077fa
Show file tree
Hide file tree
Showing 8 changed files with 942 additions and 222 deletions.
13 changes: 13 additions & 0 deletions lib/api/artifacts-leaderboard.api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ArtifactsHttpClient } from '../http-client/artifacts.http-client';
import { GetLeaderboardApiQuery, GetLeaderboardApiResult } from './types/api-schema-bindings.types';

export class ArtifactsLeaderboardApi {
constructor(private readonly httpClient: ArtifactsHttpClient) {}

/** Fetch leaderboard details. */
public getAll(params: GetLeaderboardApiQuery = {}): Promise<GetLeaderboardApiResult> {
return this.httpClient.get<GetLeaderboardApiResult>(`/leaderboard`, {
query: params,
});
}
}
8 changes: 4 additions & 4 deletions lib/api/artifacts-my-account.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ArtifactsHttpClient } from '../http-client/artifacts.http-client';
import {
ChangePasswordApiBody,
ChangePasswordApiResult,
GetBankGoldApiResult,
GetBankApiResult,
GetBankItemsApiQuery,
GetBankItemsApiResult,
} from './types/api-schema-bindings.types';
Expand All @@ -18,9 +18,9 @@ export class ArtifactsMyAccountApi {
});
}

/** Fetch golds in your bank. */
public getBankGold(): Promise<GetBankGoldApiResult> {
return this.httpClient.get<GetBankGoldApiResult>(`/my/bank/gold`, {
/** Fetch bank details. */
public getBank(): Promise<GetBankApiResult> {
return this.httpClient.get<GetBankApiResult>(`/my/bank`, {
isSecure: true,
});
}
Expand Down
16 changes: 16 additions & 0 deletions lib/api/artifacts-my-characters.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import {
GetLogsApiResult,
GetLogsApiQuery,
GetMyCharactersApiResult,
CancelTaskApiResult,
BuyExpansionApiResult,
} from './types/api-schema-bindings.types';

export class ArtifactsMyCharactersApi {
Expand Down Expand Up @@ -192,4 +194,18 @@ export class ArtifactsMyCharactersApi {
isSecure: true,
});
}

/** Cancel a task for 1 tasks coin. */
public cancelTask(name: string): Promise<CancelTaskApiResult> {
return this.httpClient.post<ExchangeTaskApiResult>(`/my/${name}/action/task/cancel`, {
isSecure: true,
});
}

/** Buy a 20 slots bank expansion. */
public buyBankExpansion(name: string): Promise<BuyExpansionApiResult> {
return this.httpClient.post<BuyExpansionApiResult>(`/my/${name}/action/bank/buy_expansion`, {
isSecure: true,
});
}
}
3 changes: 3 additions & 0 deletions lib/api/artifacts.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ArtifactsGrandExchangeApi } from './artifacts-grand-exchange.api';
import { ArtifactsAccountsApi } from './artifacts-accounts.api';
import { ArtifactsTokenApi } from './artifacts-token.api';
import { GetStatusApiResult } from './types/api-schema-bindings.types';
import { ArtifactsLeaderboardApi } from './artifacts-leaderboard.api';

export class ArtifactsApi {
public readonly myCharacters: ArtifactsMyCharactersApi;
Expand All @@ -25,6 +26,7 @@ export class ArtifactsApi {
public readonly events: ArtifactsEventsApi;
public readonly grandExchange: ArtifactsGrandExchangeApi;
public readonly token: ArtifactsTokenApi;
public readonly leaderboard: ArtifactsLeaderboardApi;

protected constructor(private readonly httpClient: ArtifactsHttpClient) {
this.myCharacters = new ArtifactsMyCharactersApi(httpClient);
Expand All @@ -38,6 +40,7 @@ export class ArtifactsApi {
this.grandExchange = new ArtifactsGrandExchangeApi(httpClient);
this.accounts = new ArtifactsAccountsApi(httpClient);
this.token = new ArtifactsTokenApi(httpClient);
this.leaderboard = new ArtifactsLeaderboardApi(httpClient);
}

public static create(params: ArtifactsApiParams = {}): ArtifactsApi {
Expand Down
44 changes: 27 additions & 17 deletions lib/api/types/api-schema-bindings.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,41 +94,41 @@ export type CreateCharacterApiBody =
export type CreateCharacterApiResult =
paths['/accounts/create']['post']['responses'][200]['content']['application/json'];

export type GetAllCharactersApiQuery = paths['/characters/']['get']['parameters']['query'];
export type GetAllCharactersApiQuery = paths['/characters']['get']['parameters']['query'];
export type GetAllCharactersApiResult =
paths['/characters/']['get']['responses'][200]['content']['application/json'];
paths['/characters']['get']['responses'][200]['content']['application/json'];

export type GetCharacterApiResult =
paths['/characters/{name}']['get']['responses'][200]['content']['application/json'];

export type GetAllEventsApiQuery = paths['/events/']['get']['parameters']['query'];
export type GetAllEventsApiQuery = paths['/events']['get']['parameters']['query'];
export type GetAllEventsApiResult =
paths['/events/']['get']['responses'][200]['content']['application/json'];
paths['/events']['get']['responses'][200]['content']['application/json'];

export type GetAllGrandExchangeApiQuery = paths['/ge/']['get']['parameters']['query'];
export type GetAllGrandExchangeApiQuery = paths['/ge']['get']['parameters']['query'];
export type GetAllGrandExchangeApiResult =
paths['/ge/']['get']['responses'][200]['content']['application/json'];
paths['/ge']['get']['responses'][200]['content']['application/json'];

export type GetGrandExchangeApiResult =
paths['/ge/{code}']['get']['responses'][200]['content']['application/json'];

export type GetAllItemsApiQuery = paths['/items/']['get']['parameters']['query'];
export type GetAllItemsApiQuery = paths['/items']['get']['parameters']['query'];
export type GetAllItemsApiResult =
paths['/items/']['get']['responses'][200]['content']['application/json'];
paths['/items']['get']['responses'][200]['content']['application/json'];

export type GetItemApiResult =
paths['/items/{code}']['get']['responses'][200]['content']['application/json'];

export type GetAllMapsApiQuery = paths['/maps/']['get']['parameters']['query'];
export type GetAllMapsApiQuery = paths['/maps']['get']['parameters']['query'];
export type GetAllMapsApiResult =
paths['/maps/']['get']['responses'][200]['content']['application/json'];
paths['/maps']['get']['responses'][200]['content']['application/json'];

export type GetMapApiResult =
paths['/maps/{x}/{y}']['get']['responses'][200]['content']['application/json'];

export type GetAllMonstersApiQuery = paths['/monsters/']['get']['parameters']['query'];
export type GetAllMonstersApiQuery = paths['/monsters']['get']['parameters']['query'];
export type GetAllMonstersApiResult =
paths['/monsters/']['get']['responses'][200]['content']['application/json'];
paths['/monsters']['get']['responses'][200]['content']['application/json'];

export type GetMonsterApiResult =
paths['/monsters/{code}']['get']['responses'][200]['content']['application/json'];
Expand All @@ -137,25 +137,35 @@ export type GetBankItemsApiQuery = paths['/my/bank/items']['get']['parameters'][
export type GetBankItemsApiResult =
paths['/my/bank/items']['get']['responses'][200]['content']['application/json'];

export type GetBankGoldApiResult =
paths['/my/bank/gold']['get']['responses'][200]['content']['application/json'];
export type GetBankApiResult =
paths['/my/bank']['get']['responses'][200]['content']['application/json'];

export type ChangePasswordApiBody =
paths['/my/change_password']['post']['requestBody']['content']['application/json'];
export type ChangePasswordApiResult =
paths['/my/change_password']['post']['responses'][200]['content']['application/json'];

export type GetAllResourcesApiQuery = paths['/resources/']['get']['parameters']['query'];
export type GetAllResourcesApiQuery = paths['/resources']['get']['parameters']['query'];
export type GetAllResourcesApiResult =
paths['/resources/']['get']['responses'][200]['content']['application/json'];
paths['/resources']['get']['responses'][200]['content']['application/json'];

export type GetResourceApiResult =
paths['/resources/{code}']['get']['responses'][200]['content']['application/json'];

export type GenerateTokenResult =
paths['/token/']['post']['responses'][200]['content']['application/json'];
paths['/token']['post']['responses'][200]['content']['application/json'];

export type DeleteCharacterApiBody =
paths['/characters/delete']['post']['requestBody']['content']['application/json'];
export type DeleteCharacterApiResult =
paths['/characters/delete']['post']['responses'][200]['content']['application/json'];

export type CancelTaskApiResult =
paths['/my/{name}/action/task/cancel']['post']['responses'][200]['content']['application/json'];

export type BuyExpansionApiResult =
paths['/my/{name}/action/bank/buy_expansion']['post']['responses'][200]['content']['application/json'];

export type GetLeaderboardApiResult =
paths['/leaderboard']['get']['responses'][200]['content']['application/json'];
export type GetLeaderboardApiQuery = paths['/leaderboard']['get']['parameters']['query'];
Loading

0 comments on commit 35077fa

Please sign in to comment.