-
Notifications
You must be signed in to change notification settings - Fork 9
/
create-codes.ts
37 lines (33 loc) · 1.24 KB
/
create-codes.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import Action from '../../action';
import { ENDPOINTS, RiotRegion } from '../../../../riot-api';
import SubmoduleMap from '../../../interfaces/submodule-map';
import { TournamentCodeParameters } from '../../../interfaces/parameters';
import { TakesBody, TakesQuery, TakesRegion } from '../../mixins';
type PostTournamentCodesQuery = {
count?: number;
tournamentId: number;
}
const BaseAction = TakesBody(
{} as TournamentCodeParameters,
TakesQuery(
{} as PostTournamentCodesQuery,
TakesRegion(
{} as RiotRegion,
Action,
),
),
);
export default class PostTournamentCodes extends BaseAction<string[]> {
constructor(submodules: SubmoduleMap, stub: boolean) {
super(submodules);
this.payload.endpoint = stub ? ENDPOINTS.TOURNAMENT_STUB.CREATE_CODE : ENDPOINTS.TOURNAMENT.CREATE_CODE;
this.payload.type = 'riot';
this.payload.method = 'POST';
}
public async exec(): Promise<string[]> {
if (!this.payload.query || !Object.keys(this.payload.query).includes('tournamentId')) {
throw new Error('[galeforce]: POST to /lol/tournament/v4/codes requires a query with a tournamentId parameter.');
}
return super.exec();
}
}