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

export const PAYMENT_TERM_ROUTES = {
    INDEX: "/api/payment-terms",
    BY_ID: "/api/payment-terms/{id}",
    SET_DEFAULT: "/api/set-default-payment-term",
} as const satisfies Record<string, ApiPath>

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

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