import {z} from 'zod' export type DeleteApiPayablesPayerAccountsPayerIdPayeesIdArgs = {Authorization: string, payer_id: string, id: string}; export type DeleteApiPayablesPayerAccountsPayerIdPayeesIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const deleteApiPayablesPayerAccountsPayerIdPayeesIdResponse = z.object({id: z.string(), type: z.string(), data: z.object({id: z.string().optional(), type: z.string().optional(), payer_account_id: z.string().optional(), name: z.string().optional(), entity_type: z.enum(["c_corporation", "s_corporation", "partnership", "limited_liability_company", "sole_proprietorship"]).optional(), email: z.string().nullable().optional(), tax_id_last4: z.string().optional(), address: z.object({line1: z.string().optional(), line2: z.string().nullable().optional(), city: z.string().optional(), state: z.string().optional(), postal_code: z.string().optional(), country: z.literal("USA").optional()}).optional(), receiving_bank_account_id: z.string().nullable().optional(), business_id: z.string().nullable().optional(), status: z.enum(["pending", "active", "disabled", "archived"]).optional(), metadata: z.object({}).optional(), created_at: z.string().optional(), updated_at: z.string().optional()}), page_info: z.unknown()}); 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 }; /** * Archive a Payee * * DELETE /payables/payer_accounts/{payer_id}/payees/{id} */ export const deleteApiPayablesPayerAccountsPayerIdPayeesId = async (args: DeleteApiPayablesPayerAccountsPayerIdPayeesIdArgs, options?: DeleteApiPayablesPayerAccountsPayerIdPayeesIdOptions) => { const {baseUrl = "https://api.justifi.ai/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) const url = `${baseUrl.replace(/\/+$/, '')}/payables/payer_accounts/${encodeURIComponent(String(args.payer_id))}/payees/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(deleteApiPayablesPayerAccountsPayerIdPayeesIdResponse, await res.json()) };