unit TwitchAPI;

interface

uses
  TwitchAPI.Client,
  TwitchAPI.Commands.GetChannelInfo,
  TwitchAPI.Commands.GetExtensionAnalytics,
  TwitchAPI.Commands.GetUsers;

type

{ TTwitch }

  TTwitch = class
  private
    FClient: TTwitchClient;
  public
    constructor Create(const AClientID: string = ''; const AToken: string = '');
    destructor Destroy; override;
    function CreateCommand<T: TTwitchCommand>(): T;
    function GetChannelInfo: ITwitchGetChannelInfoCommand;
    function GetExtensionAnalytics: ITwitchGetExtensionAnalyticsCommand;
    function GetUsers: ITwitchGetUsersCommand;
  end;

implementation

uses
  System.SysUtils,
  TwitchAPI.Commands.GetChannelInfo.Impl,
  TwitchAPI.Commands.GetExtensionAnalytics.Impl,
  TwitchAPI.Commands.GetUsers.Impl;

{ TTwitch }

constructor TTwitch.Create(const AClientID: string = ''; const AToken: string = '');
begin
  inherited Create;
  FClient := TTwitchClient.Create(AClientID, AToken);
end;

destructor TTwitch.Destroy;
begin
  if Assigned(FClient) then
    FreeAndNil(FClient);
  inherited Destroy;
end;

function TTwitch.CreateCommand<T>(): T;
begin
  Result := T.Create(FClient);
end;

function TTwitch.GetChannelInfo: ITwitchGetChannelInfoCommand;
begin
  Result := TTwitchGetChannelInfoCommand.Create(FClient);
end;

function TTwitch.GetExtensionAnalytics: ITwitchGetExtensionAnalyticsCommand;
begin
  Result := TTwitchGetExtensionAnalyticsCommand.Create(FClient);
end;

function TTwitch.GetUsers: ITwitchGetUsersCommand;
begin
  Result := TTwitchGetUsersCommand.Create(FClient);
end;

end.
