mirror of
https://github.com/tribufu/sdk-js
synced 2025-06-17 02:54:18 +00:00
Add files endpoint
This commit is contained in:
34
src/api.ts
34
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
|
* @param page
|
||||||
* @returns Server[]
|
* @returns Server[]
|
||||||
*/
|
*/
|
||||||
@ -391,4 +391,36 @@ export class TribufuApi {
|
|||||||
|
|
||||||
return responseBody;
|
return responseBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get files from the Tribufu API.
|
||||||
|
* @param page
|
||||||
|
* @returns File[]
|
||||||
|
*/
|
||||||
|
public async getFiles(page: number = 1): Promise<any[]> {
|
||||||
|
const headers = this.getHeaders();
|
||||||
|
const responseBody = await this.http.get<any[]>(`/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<any> {
|
||||||
|
const headers = this.getHeaders()
|
||||||
|
const responseBody = await this.http.get<any>(`/v1/files/${id}`, headers);
|
||||||
|
|
||||||
|
if (!responseBody) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseBody;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user