import { CrudClient } from "../infra/crud-client"
import type { ApiClientOptions } from "../infra/client"
import type { ApiPath, ApiRequestBody } from "../infra/types"

export const SERVICE_ROUTES = {
    INDEX: "/api/services",
    BY_ID: "/api/services/{id}",
    IMPORT: "/api/import-services",
    EXPORT: "/api/export-services",
} as const satisfies Record<string, ApiPath>

export class ServicesClient extends CrudClient<
    typeof SERVICE_ROUTES.INDEX,
    typeof SERVICE_ROUTES.BY_ID
> {
    constructor(baseUrl?: string, defaultOptions?: ApiClientOptions) {
        super(baseUrl, defaultOptions, SERVICE_ROUTES.INDEX, SERVICE_ROUTES.BY_ID)
    }

    async import(payload: ApiRequestBody<typeof SERVICE_ROUTES.IMPORT, "post">) {
        return this.post(SERVICE_ROUTES.IMPORT, payload)
    }

    async export(payload: ApiRequestBody<typeof SERVICE_ROUTES.EXPORT, "post">) {
        return this.post(SERVICE_ROUTES.EXPORT, payload)
    }
}
