of<T extends BaseTwitchOpenApi> method

T of<T extends BaseTwitchOpenApi>({
  1. required String? bearerToken,
})

Return an instance of subclass BaseTwitchOpenApi. The instances available are:

Implementation

T of<T extends BaseTwitchOpenApi>({required String? bearerToken}) {
  switch (T) {
    case TwitchChannelInformation:
      return TwitchChannelInformationImpl(
        clientId: clientId,
        token: bearerToken,
      ) as T;
    case TwitchSearch:
      return TwitchSearchImpl(
        clientId: clientId,
        token: bearerToken,
      ) as T;
    case TwitchGame:
      return TwitchGameImpl(
        clientId: clientId,
        token: bearerToken,
      ) as T;
    case TwitchChannelMedia:
      return TwitchChannelMediaImpl(
        clientId: clientId,
        token: bearerToken,
      ) as T;
    default:
      throw UnsupportedError(
        'typeof($T) is not implemented in TwitchManagerOpenApi.getInstance',
      );
  }
}