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

export const REFERRAL_SOURCE_ROUTES = {
    INDEX: "/api/referral-sources",
    BY_ID: "/api/referral-sources/{id}",
    SET_DEFAULT: "/api/set-default-referral-source",
} as const satisfies Record<string, ApiPath>

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

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