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

export const TAX_ROUTES = {
    INDEX: "/api/taxes",
    BY_ID: "/api/taxes/{id}",
    SET_DEFAULT: "/api/set-default-tax",
    REMOVE_DEFAULT: "/api/remove-default-tax",
} as const satisfies Record<string, ApiPath>

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

    async setDefault(payload: ApiRequestBody<typeof TAX_ROUTES.SET_DEFAULT, "post">) {
        return this.post(TAX_ROUTES.SET_DEFAULT, payload)
    }

    async removeDefault(payload: ApiRequestBody<typeof TAX_ROUTES.REMOVE_DEFAULT, "post">) {
        return this.post(TAX_ROUTES.REMOVE_DEFAULT, payload)
    }
}
