import {z} from 'zod' export type GetApiInventoryInventoryadjustmentV1GetAllInventoryAdjustmentsArgs = {authenticationtoken: string, componentRecipeAdjustmentFlag?: boolean | undefined, daypartCode?: string | undefined, entryDate: string, includeDetails?: boolean | undefined, locationCode: string, minutesSinceUpdate?: number | undefined, password: string, sitename: string, transactionNumber?: string | undefined, userid: string, 'X-B3-TraceId'?: string | undefined, includeNull?: boolean | undefined}; export type GetApiInventoryInventoryadjustmentV1GetAllInventoryAdjustmentsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const inventoryAdjustmentDetailsDtoGet = z.object({lotNumber: z.string().optional(), packageType: z.string().optional(), productName: z.string().optional(), productNumber: z.string(), qualitativeJudgment: z.string(), quantity: z.number(), recipeName: z.string().optional(), recipeQuantity: z.number().optional(), storageCode: z.string().optional(), transactionDate: z.string().optional(), value: z.number().optional(), unitCost: z.number().optional(), recipeValue: z.number().optional()}); export const inventoryAdjustmentHeaderGetDto = z.object({componentRecipeAdjustmentFlag: z.string().optional(), daypartCode: z.number().int().optional(), entryUser: z.string().optional(), locationCode: z.string().optional(), memo: z.string().optional(), transactionNumber: z.string().optional(), transactionDate: z.string().optional(), transactionValue: z.number().optional()}); export const inventoryAdjustmentDetailsGet = z.object({inventoryAdjustmentDetailDetails: z.array(inventoryAdjustmentDetailsDtoGet).optional(), inventoryAdjustmentHeaderDetails: inventoryAdjustmentHeaderGetDto.optional()}); export const getApiInventoryInventoryadjustmentV1GetAllInventoryAdjustmentsResponse = z.array(inventoryAdjustmentDetailsGet); 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 }; /** * getAllInventoryAdjustments * * GET /inventory/inventoryadjustment/v1/getAllInventoryAdjustments */ export const getApiInventoryInventoryadjustmentV1GetAllInventoryAdjustments = async (args: GetApiInventoryInventoryadjustmentV1GetAllInventoryAdjustmentsArgs, options: GetApiInventoryInventoryadjustmentV1GetAllInventoryAdjustmentsOptions) => { 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.componentRecipeAdjustmentFlag != null) query.append("componentRecipeAdjustmentFlag", String(args.componentRecipeAdjustmentFlag)) if (args.daypartCode != null) query.append("daypartCode", String(args.daypartCode)) if (args.entryDate != null) query.append("entryDate", String(args.entryDate)) if (args.includeDetails != null) query.append("includeDetails", String(args.includeDetails)) if (args.locationCode != null) query.append("locationCode", String(args.locationCode)) if (args.minutesSinceUpdate != null) query.append("minutesSinceUpdate", String(args.minutesSinceUpdate)) if (args.password != null) headers.set("password", String(args.password)) if (args.sitename != null) headers.set("sitename", String(args.sitename)) if (args.transactionNumber != null) query.append("transactionNumber", String(args.transactionNumber)) 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(/\/+$/, '')}/inventory/inventoryadjustment/v1/getAllInventoryAdjustments${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(getApiInventoryInventoryadjustmentV1GetAllInventoryAdjustmentsResponse, await res.json()) };