import {z} from 'zod' export type WireInRequestUpdateRequestBody = {date_sent: string, bank_name: string, amount_sent: string, additional_notes?: string | undefined}; export type UpdateApiV1WireInRequestsWireInRequestUuidArgs = {'X-Gusto-API-Version'?: '2026-06-15' | undefined, wire_in_request_uuid: string, body: WireInRequestUpdateRequestBody}; export type UpdateApiV1WireInRequestsWireInRequestUuidOptions = {baseUrl?: string | undefined, CompanyAccessAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const wireInRequest = z.object({uuid: z.string().optional(), status: z.enum(["awaiting_funds", "pending_review", "approved", "canceled"]).optional(), origination_bank: z.string().optional(), origination_bank_address: z.string().optional(), recipient_name: z.string().optional(), recipient_address: z.string().optional(), recipient_account_number: z.string().optional(), recipient_routing_number: z.string().optional(), additional_notes: z.string().nullable().optional(), bank_name: z.string().nullable().optional(), date_sent: z.string().nullable().optional(), unique_tracking_code: z.string().optional(), payment_type: z.enum(["Payroll", "ContractorPaymentGroup"]).optional(), payment_uuid: z.string().optional(), amount_sent: z.string().nullable().optional(), requested_amount: z.string().optional(), wire_in_deadline: z.string().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 }; /** * Submit a wire in request * * PUT /v1/wire_in_requests/{wire_in_request_uuid} */ export const updateApiV1WireInRequestsWireInRequestUuid = async (args: UpdateApiV1WireInRequestsWireInRequestUuidArgs, options?: UpdateApiV1WireInRequestsWireInRequestUuidOptions) => { 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/wire_in_requests/${encodeURIComponent(String(args.wire_in_request_uuid))}${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(wireInRequest, await res.json()) };