import {z} from 'zod' export type GetApiInventoryPhysicalinventorystandardV1GetAllPhysicalInventoryStandardsArgs = {authenticationtoken: string, inventoryDate: string, locationCode: string, password: string, productNumber?: string | undefined, sitename: string, storageCode?: string | undefined, userid: string, userIdForDetails?: string | undefined, 'X-B3-TraceId'?: string | undefined, includeNull?: boolean | undefined}; export type GetApiInventoryPhysicalinventorystandardV1GetAllPhysicalInventoryStandardsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const physicalInventoryStandardDetails00 = z.object({altQuantity1: z.number().optional(), altQuantity2: z.number().optional(), altQuantity3: z.number().optional(), inventoryDate: z.string(), productNumber: z.string(), quantity: z.number().optional(), storageCode: z.string(), userId: z.string(), inventoryType: z.string().optional(), detail: z.string().optional(), inventoryUnit: z.string().optional(), totalQuantity: z.number().optional(), unitPrice: z.number().optional(), physicalValue: z.number().optional(), byExceptionFlag: z.string().optional()}); export const physicalInventoryStandardDetailsGet = z.object({physicalInventoryStandardDetailDetails: z.array(physicalInventoryStandardDetails00).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 }; /** * getAllPhysicalInventoryStandards * * GET /inventory/physicalinventorystandard/v1/getAllPhysicalInventoryStandards */ export const getApiInventoryPhysicalinventorystandardV1GetAllPhysicalInventoryStandards = async (args: GetApiInventoryPhysicalinventorystandardV1GetAllPhysicalInventoryStandardsArgs, options: GetApiInventoryPhysicalinventorystandardV1GetAllPhysicalInventoryStandardsOptions) => { 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.inventoryDate != null) query.append("inventoryDate", String(args.inventoryDate)) if (args.locationCode != null) query.append("locationCode", String(args.locationCode)) if (args.password != null) headers.set("password", String(args.password)) if (args.productNumber != null) query.append("productNumber", String(args.productNumber)) if (args.sitename != null) headers.set("sitename", String(args.sitename)) if (args.storageCode != null) query.append("storageCode", String(args.storageCode)) if (args.userid != null) headers.set("userid", String(args.userid)) if (args.userIdForDetails != null) query.append("userIdForDetails", String(args.userIdForDetails)) 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/physicalinventorystandard/v1/getAllPhysicalInventoryStandards${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(physicalInventoryStandardDetailsGet, await res.json()) };