Skip to content

Commit

Permalink
add HelixGame#getStreams(Paginated)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-fischer committed Dec 15, 2020
1 parent 6b7ba8c commit e6ff84a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion packages/twitch/src/API/Helix/Game/HelixGame.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Enumerable } from '@d-fischer/shared-utils';
import { rtfm } from 'twitch-common';
import type { ApiClient } from '../../../ApiClient';
import type { HelixPaginatedRequest } from '../HelixPaginatedRequest';
import type { HelixPagination } from '../HelixPagination';
import type { HelixPaginatedResponse } from '../HelixResponse';
import type { HelixStream, HelixStreamData } from '../Stream/HelixStream';

export interface HelixGameData {
id: string;
Expand All @@ -14,7 +18,7 @@ export interface HelixGameData {
@rtfm<HelixGame>('twitch', 'HelixGame', 'id')
export class HelixGame {
@Enumerable(false) private readonly _data: HelixGameData;
/** @private */ @Enumerable(false) protected readonly _client: ApiClient;
@Enumerable(false) private readonly _client: ApiClient;

/** @private */
constructor(data: HelixGameData, client: ApiClient) {
Expand Down Expand Up @@ -42,4 +46,18 @@ export class HelixGame {
get boxArtUrl(): string {
return this._data.box_art_url;
}

/**
* Retrieves streams that are currently playing the game.
*/
async getStreams(pagination?: HelixPagination): Promise<HelixPaginatedResponse<HelixStream>> {
return this._client.helix.streams.getStreams({ ...pagination, game: this._data.id });
}

/**
* Creates a paginator for streams that are currently playing the game.
*/
getStreamsPaginated(): HelixPaginatedRequest<HelixStreamData, HelixStream> {
return this._client.helix.streams.getStreamsPaginated({ game: this._data.id });
}
}

0 comments on commit e6ff84a

Please sign in to comment.