import {z} from 'zod' export type CreateApiV1AgentHubApplyPayeesArgs = {body: {type: 'sole_prop' | 'business', personal_info: {first_name: string, last_name: string, ssn: string, dob: string}, business_info?: ({legal_name: string, ein: string, irs_filing_type: '"A"' | '"B"' | '"C"' | '"D"' | '"F"' | '"G"' | '"J"' | '"N"'}) | undefined, contact_info: {email: string, phone_number: string}, address_info: {street: string, city: string, zip_code: string, county_code: string}, banking_info: {dda: string, routing: string}, foundation_date: string, date_incorporated: string}}; export type CreateApiV1AgentHubApplyPayeesOptions = {baseUrl?: string | undefined, sec0?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiV1AgentHubApplyPayeesResponse = z.object({data: z.object({object: z.string().optional(), id: z.string().optional(), name: z.string().optional(), industry: z.unknown(), processing_type: z.string().optional(), isv_merchant_type: z.string().optional(), isv_process_own_transactions: z.unknown(), merchant_category: z.unknown(), hubspot_record_id: z.unknown(), bank_account_type: z.unknown(), agent_name: z.string().optional(), agent_tag_values: z.object({id: z.number().int().optional(), category: z.string().optional(), item: z.string().optional(), color: z.string().optional(), agent_id: z.number().int().optional(), user_id: z.unknown(), created_at: z.unknown(), updated_at: z.unknown()}).optional(), agent_id: z.number().int().optional(), agent_parent_id: z.unknown(), agent_parent_name: z.unknown(), apply_pricing_template_id: z.unknown(), apply_pricing_template_name: z.string().optional(), step: z.unknown(), is_copied: z.unknown(), created_at: z.string().optional(), updated_at: z.string().optional(), status: z.string().optional(), completed: z.number().int().optional(), lead_status: z.unknown(), hardware_shippings: z.unknown(), status_id: z.number().int().optional(), signature_override: z.unknown(), giact_failed_checks: z.unknown(), electronic_signature_full_name: z.unknown(), possible_duplicates: z.array(z.unknown()).optional()}).optional(), meta: z.object({include: z.array(z.unknown()).optional(), custom: z.array(z.unknown()).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 }; /** * Create Payee * * POST /v1/agent-hub/apply/payees */ export const createApiV1AgentHubApplyPayees = async (args: CreateApiV1AgentHubApplyPayeesArgs, options?: CreateApiV1AgentHubApplyPayeesOptions) => { const {baseUrl = "https://testapi.payarc.net", 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(/\/+$/, '')}/v1/agent-hub/apply/payees${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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(createApiV1AgentHubApplyPayeesResponse, await res.json()) };