import {z} from 'zod' export type PatchApiContractorsContractorCOPYArgs = {contractor: string, body: {type?: string | undefined, first_name?: string | undefined, middle_name?: string | undefined, last_name?: string | undefined, business_name?: string | undefined, dob?: string | undefined, start_date?: string | undefined, termination_date?: string | undefined, workplaces?: Array | undefined, primary_workplace?: string | undefined, email?: string | undefined, ssn?: string | undefined, ein?: string | undefined, default_net_pay_split?: string | undefined, address?: ({line1: string, line2?: string | undefined, city: string, state: string, postal_code: string, country?: string | undefined}) | undefined, '1099_nec_electronic_consent_provided'?: boolean | undefined, metadata?: unknown | undefined}}; export type PatchApiContractorsContractorCOPYOptions = {baseUrl?: string | undefined, sec0?: string | undefined, fetch?: typeof fetch | undefined}; export const patchApiContractorsContractorCOPYResponse = z.object({}); 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 contractor * * PATCH /contractors/{contractor} (COPY) */ export const patchApiContractorsContractorCOPY = async (args: PatchApiContractorsContractorCOPYArgs, options?: PatchApiContractorsContractorCOPYOptions) => { const {baseUrl = "https://sandbox.checkhq.com", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (sec0 !== undefined) headers.set("Authorization", sec0) const url = `${baseUrl.replace(/\/+$/, '')}/contractors/${encodeURIComponent(String(args.contractor))} (COPY)${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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(patchApiContractorsContractorCOPYResponse, await res.json()) };