import { ResponseType } from "axios";

export interface ICustomParams {
  url?: string;
  path?: string;
  method: "get" | "delete" | "head" | "options" | "post" | "put" | "patch";
  signal?: AbortSignal;
  responseType?: ResponseType;
  headers?: {
    [key: string]: any;
  };
  [key: string]: unknown;
}

export interface IDataSource {
  getBaseUrl(): string;
  getList<T>(resource: string, params?: Record<string, unknown>): Promise<T>;
  getOne<T>(resource: string, id: string | number, params?: Record<string, unknown>): Promise<T>;
  getMany<T, R>(resource: string, ids: Array<string | number>): Promise<R>;
  createOne<T>(resource: string, data: Partial<T>, params?: Record<string, unknown>): Promise<T>;
  updateOne<T>(
    resource: string,
    id: string | number,
    data: Partial<T>,
    params?: Record<string, unknown>
  ): Promise<T>;
  deleteOne<T>(
    resource: string,
    id: string | number,
    params?: Record<string, unknown>
  ): Promise<void>;

  custom: <R>(customParams: ICustomParams) => Promise<R>;
}
