import * as interfaces from '../ts_interfaces/index.js';
import type { DcRouterApiClient } from './classes.dcrouterapiclient.js';

export class LogManager {
  private clientRef: DcRouterApiClient;

  constructor(clientRef: DcRouterApiClient) {
    this.clientRef = clientRef;
  }

  public async getRecent(options?: {
    level?: 'debug' | 'info' | 'warn' | 'error';
    category?: 'smtp' | 'dns' | 'security' | 'system' | 'email';
    limit?: number;
    offset?: number;
    search?: string;
    timeRange?: string;
  }): Promise<interfaces.requests.IReq_GetRecentLogs['response']> {
    return this.clientRef.request<interfaces.requests.IReq_GetRecentLogs>(
      'getRecentLogs',
      this.clientRef.buildRequestPayload(options || {}) as any,
    );
  }

  public async getStream(options?: {
    follow?: boolean;
    filters?: {
      level?: string[];
      category?: string[];
    };
  }): Promise<interfaces.requests.IReq_GetLogStream['response']> {
    return this.clientRef.request<interfaces.requests.IReq_GetLogStream>(
      'getLogStream',
      this.clientRef.buildRequestPayload(options || {}) as any,
    );
  }
}
