import {z} from 'zod' export type PaymentConfigsUpdateRequest = {payment_configs?: ({payment_speed?: ('1-day' | '2-day' | '4-day') | undefined, fast_payment_limit?: (number | null) | undefined, partner_owned_disbursement?: boolean | undefined}) | undefined}; export type UpdateApiV1CompaniesCompanyUuidPaymentConfigsArgs = {'X-Gusto-API-Version'?: '2026-06-15' | undefined, company_uuid: string, body: PaymentConfigsUpdateRequest}; export type UpdateApiV1CompaniesCompanyUuidPaymentConfigsOptions = {baseUrl?: string | undefined, CompanyAccessAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const paymentConfigs = z.object({company_uuid: z.string().optional(), partner_uuid: z.string().optional(), fast_payment_limit: z.string().nullable().optional(), payment_speed: z.enum(["1-day", "2-day", "4-day"]).optional(), partner_owned_disbursement: z.boolean().optional(), earned_fast_ach_blockers: z.array(z.object({blocker_type: z.enum(["minimum_days", "minimum_funded_payments"]).optional(), threshold: z.number().optional()})).optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Update a company's payment configs * * PUT /v1/companies/{company_uuid}/payment_configs */ export const updateApiV1CompaniesCompanyUuidPaymentConfigs = async (args: UpdateApiV1CompaniesCompanyUuidPaymentConfigsArgs, options?: UpdateApiV1CompaniesCompanyUuidPaymentConfigsOptions) => { const {baseUrl = "https://api.gusto-demo.com", fetch: fetchFn = fetch, CompanyAccessAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['X-Gusto-API-Version'] != null) headers.set("X-Gusto-API-Version", String(args['X-Gusto-API-Version'])) if (CompanyAccessAuth !== undefined) headers.set('authorization', `Bearer ${CompanyAccessAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/companies/${encodeURIComponent(String(args.company_uuid))}/payment_configs${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(paymentConfigs, await res.json()) };