import {z} from 'zod' export type FeeCodeAmountModel = {version?: number | undefined, feeCode: string, amount: number, description: string, quantity: number, feeChargeTypeCd: string, feeChargeTypeDesc: string}; export type MaintenanceFeeShoppingCartItemModel = {version?: number | undefined, shoppingCartItemId: number, storefrontReferenceIdName: string, storefrontReferenceId2Name: string, storefrontReferenceId: string, storefrontReferenceId2: string, itemUrl: string, submittedDate: string, feeCodes?: Array | undefined, expirationDateMessage: string, attorneyDocketNumber: string, expired?: boolean | undefined, payable?: boolean | undefined, entityTypeCd: string, entityTypeName: string, window: string, surchargeDate: string, closeDate: string, feeStatus: string}; export type CreateApiMntfeeServicesV2MaintenancefeeAttributesArgs = {caresActSelected?: boolean | undefined, body: Array}; export type CreateApiMntfeeServicesV2MaintenancefeeAttributesOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const createApiMntfeeServicesV2MaintenancefeeAttributesResponse = z.string(); 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 }; /** * Retrieves the pricing attributes for the given items * * POST /mntfee-services/v2/maintenancefee/attributes */ export const createApiMntfeeServicesV2MaintenancefeeAttributes = async (args: CreateApiMntfeeServicesV2MaintenancefeeAttributesArgs, options: CreateApiMntfeeServicesV2MaintenancefeeAttributesOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.caresActSelected != null) query.append("caresActSelected", String(args.caresActSelected)) const url = `${baseUrl.replace(/\/+$/, '')}/mntfee-services/v2/maintenancefee/attributes${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(createApiMntfeeServicesV2MaintenancefeeAttributesResponse, await res.json()) };