import {z} from 'zod' export type PlacementInformationPatch = {accountNumber: string, accountNamespace: string, accountRelationship: 'SIGNER', accountOpenDate?: string | undefined, brandId?: string | undefined, productType?: ('AUTO' | 'BNPL' | 'CARD' | 'DDA' | 'FITNESS' | 'HEL' | 'HELOC' | 'PRESETTLEMENT' | 'POSTSETTLEMENT' | 'POSTCHARGEOFF' | 'UNSECURED' | 'UTILITY') | undefined, productDescription?: string | undefined, dateAssigned?: string | undefined, expectedRetractionDate?: string | undefined, firstName?: string | undefined, lastName?: string | undefined, middleName?: string | undefined, email1?: string | undefined, email2?: string | undefined, email3?: string | undefined, telephone1?: string | undefined, telephoneType1?: ('HOME' | 'WORK' | 'CELL' | 'FAX' | 'BUSINESS') | undefined, telephoneSMSConsent1?: ('YES' | 'NO') | undefined, telephoneVMConsent1?: ('YES' | 'NO') | undefined, telephone2?: string | undefined, telephoneType2?: ('HOME' | 'WORK' | 'CELL' | 'FAX' | 'BUSINESS') | undefined, telephoneSMSConsent2?: ('YES' | 'NO') | undefined, telephoneVMConsent2?: ('YES' | 'NO') | undefined, telephone3?: string | undefined, telephoneType3?: ('HOME' | 'WORK' | 'CELL' | 'FAX' | 'BUSINESS') | undefined, telephoneSMSConsent3?: ('YES' | 'NO') | undefined, telephoneVMConsent3?: ('YES' | 'NO') | undefined, addressLine1?: string | undefined, addressLine2?: string | undefined, addressLine3?: string | undefined, addressType?: ('HOME' | 'WORK') | undefined, city?: string | undefined, state?: string | undefined, zipcode?: string | undefined, totalAmountDue?: number | undefined, currentAmountDue?: number | undefined, currentBalance?: number | undefined, totalDelinquentAmount?: number | undefined, delinquencyDate?: string | undefined, cyclesDelinquent?: number | undefined, displayAccountNumberLast4?: string | undefined, customerNumber?: string | undefined, originalCreditor?: string | undefined, currentCreditor?: string | undefined, originalAccountNumber?: string | undefined}; export type PatchApiInboundV1PlacementArgs = {body: Array}; export type PatchApiInboundV1PlacementOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const inboundAPIResponse200 = z.object({ClientId: z.string(), Status: z.string(), Message: z.string(), ProcessedRecords: z.number().int()}); 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 Account Information * * PATCH /inbound/v1/placement */ export const patchApiInboundV1Placement = async (args: PatchApiInboundV1PlacementArgs, options?: PatchApiInboundV1PlacementOptions) => { const {baseUrl = "https://virtserver.swaggerhub.com/felipediazc/integration/0.0.2", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (ApiKeyAuth !== undefined) headers.set("X-API-KEY", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/inbound/v1/placement${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(inboundAPIResponse200, await res.json()) };