import {z} from 'zod' export type GetApiCustomerorderenhancedV1GetAllCustomerOrderEnhancedArgs = {authenticationtoken: string, cateringOrderFlag?: boolean | undefined, customerCode?: string | undefined, daypartCode?: number | undefined, expectedDeliveryDate?: string | undefined, includeDetails?: boolean | undefined, invoiceDate?: string | undefined, locationCode: string, orderDate?: string | undefined, orderNumber?: string | undefined, orderStatus?: ('SUBMITTED' | '18' | 'PICKLISTED' | '19' | 'INVOICED' | '2' | 'CANCELED' | '4' | 'FINALRECONCILED' | '3') | undefined, password: string, postDate?: string | undefined, referenceNumber?: string | undefined, revenueCenter?: string | undefined, sitename: string, userid: string, 'X-B3-TraceId'?: string | undefined, includeNull?: boolean | undefined}; export type GetApiCustomerorderenhancedV1GetAllCustomerOrderEnhancedOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const customerOrderEnhancedDetailGet = z.object({completeTaxRate: z.string(), conversionInventoryIssueUnit: z.string(), fillQuantity: z.number().optional(), finalReconcileQuantity: z.number().optional(), inventoryPrice: z.number().optional(), inventoryUnit: z.string(), invoiceQuantity: z.number().optional(), issueUnit: z.string(), orderQuantity: z.number(), productName: z.string(), productNumber: z.string(), storageLocation: z.string(), storageLocationCode: z.string(), taxCode: z.string(), taxDescription: z.string(), taxValue: z.string().optional(), unitPrice: z.number().optional(), storageLocationName: z.string().optional()}); export const customerOrderEnhancedHeaderDtoGet = z.object({cateringOrder: z.string().optional(), customerCode: z.string(), customerName: z.string().optional(), dailyPrepDate: z.string().optional(), dailyPrepDescription: z.string().optional(), daypartCode: z.number().int().optional(), daypartDescription: z.string().optional(), entryUser: z.string().optional(), expectedDeliveryDate: z.string().optional(), finalReconcileDate: z.string().optional(), finalReconcileUser: z.string().optional(), finalReconcileValue: z.string().optional(), invoiceDate: z.string().optional(), invoiceUser: z.string().optional(), invoiceValue: z.string().optional(), locationCode: z.string(), locationName: z.string().optional(), orderDate: z.string().optional(), orderNumber: z.string().optional(), orderStatus: z.enum(["CANCELED", "FINALRECONCILED", "INVOICED", "PICKLISTED", "SUBMITTED"]).optional(), postDate: z.string().optional(), referenceNumber: z.string().optional(), revenueCenter: z.string().optional(), revenueCenterDescription: z.string().optional(), grandTotal: z.string().optional(), taxTotal: z.string().optional()}); export const customerOrderEnhancedDetailsGet = z.object({customerOrderEnhancedDetailDetails: z.array(customerOrderEnhancedDetailGet).optional(), customerOrderEnhancedHeaderDetails: customerOrderEnhancedHeaderDtoGet.optional()}); export const getApiCustomerorderenhancedV1GetAllCustomerOrderEnhancedResponse = z.array(customerOrderEnhancedDetailsGet); 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 }; /** * getAllCustomerOrderEnhanced * * GET /customerorderenhanced/v1/getAllCustomerOrderEnhanced */ export const getApiCustomerorderenhancedV1GetAllCustomerOrderEnhanced = async (args: GetApiCustomerorderenhancedV1GetAllCustomerOrderEnhancedArgs, options: GetApiCustomerorderenhancedV1GetAllCustomerOrderEnhancedOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.authenticationtoken != null) headers.set("authenticationtoken", String(args.authenticationtoken)) if (args.cateringOrderFlag != null) query.append("cateringOrderFlag", String(args.cateringOrderFlag)) if (args.customerCode != null) query.append("customerCode", String(args.customerCode)) if (args.daypartCode != null) query.append("daypartCode", String(args.daypartCode)) if (args.expectedDeliveryDate != null) query.append("expectedDeliveryDate", String(args.expectedDeliveryDate)) if (args.includeDetails != null) query.append("includeDetails", String(args.includeDetails)) if (args.invoiceDate != null) query.append("invoiceDate", String(args.invoiceDate)) if (args.locationCode != null) query.append("locationCode", String(args.locationCode)) if (args.orderDate != null) query.append("orderDate", String(args.orderDate)) if (args.orderNumber != null) query.append("orderNumber", String(args.orderNumber)) if (args.orderStatus != null) query.append("orderStatus", String(args.orderStatus)) if (args.password != null) headers.set("password", String(args.password)) if (args.postDate != null) query.append("postDate", String(args.postDate)) if (args.referenceNumber != null) query.append("referenceNumber", String(args.referenceNumber)) if (args.revenueCenter != null) query.append("revenueCenter", String(args.revenueCenter)) if (args.sitename != null) headers.set("sitename", String(args.sitename)) if (args.userid != null) headers.set("userid", String(args.userid)) if (args['X-B3-TraceId'] != null) headers.set("X-B3-TraceId", String(args['X-B3-TraceId'])) if (args.includeNull != null) query.append("includeNull", String(args.includeNull)) const url = `${baseUrl.replace(/\/+$/, '')}/customerorderenhanced/v1/getAllCustomerOrderEnhanced${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(getApiCustomerorderenhancedV1GetAllCustomerOrderEnhancedResponse, await res.json()) };