diff --git a/src/api.ts b/src/api.ts index 7367f9c..3455964 100644 --- a/src/api.ts +++ b/src/api.ts @@ -240,7 +240,7 @@ export class TribufuApi { } /** - * Get a game from the Tribufu API. + * Get servers from the Tribufu API. * @param page * @returns Server[] */ @@ -391,4 +391,36 @@ export class TribufuApi { return responseBody; } + + /** + * Get files from the Tribufu API. + * @param page + * @returns File[] + */ + public async getFiles(page: number = 1): Promise { + const headers = this.getHeaders(); + const responseBody = await this.http.get(`/v1/files?page=${page}`, headers); + + if (!responseBody) { + return []; + } + + return responseBody; + } + + /** + * Get a file by id from the Tribufu API. + * @param id + * @returns File | null + */ + public async getFileById(id: string): Promise { + const headers = this.getHeaders() + const responseBody = await this.http.get(`/v1/files/${id}`, headers); + + if (!responseBody) { + return null; + } + + return responseBody; + } }