// Auto-generated by AutoCRUD Web Generator
import { client } from '../../lib/client';
import type { Quest } from '../types';
import type {
  ResourceMeta,
  RevisionInfo,
  FullResource,
  RevisionListResponse,
  RevisionListParams,
  SearchParams,
} from '../../types/api';

const BASE = '/v1/autocrud/quest';

export const questApi = {
  create: (data: Quest) => client.post<RevisionInfo>(BASE, data),

  list: (params?: SearchParams & { returns?: string }) =>
    client.get<FullResource<Quest>[]>(BASE, { params }),

  count: (params?: SearchParams) => client.get<number>(`${BASE}/count`, { params }),

  get: (
    id: string,
    params?: {
      revision_id?: string;
      partial?: string[];
      returns?: string;
      include_deleted?: boolean;
    },
  ) => client.get<FullResource<Quest>>(`${BASE}/${id}`, { params }),

  update: (id: string, data: Quest, params?: { change_status?: string; mode?: string }) =>
    client.put<RevisionInfo>(`${BASE}/${id}`, data, { params }),

  delete: (id: string) => client.delete<ResourceMeta>(`${BASE}/${id}`),

  permanentlyDelete: (id: string) => client.delete<ResourceMeta>(`${BASE}/${id}/permanently`),

  restore: (id: string) => client.post<ResourceMeta>(`${BASE}/${id}/restore`),

  revisionList: (id: string, params?: RevisionListParams) =>
    client.get<RevisionListResponse>(`${BASE}/${id}/revision-list`, { params }),

  switchRevision: (id: string, revisionId: string) =>
    client.post<ResourceMeta>(`${BASE}/${id}/switch/${revisionId}`),
};
