import {z} from 'zod' export type InventorySettingsDto = {defaultItemMarkup?: (number | unknown) | undefined, expiryTrackingEnabled?: boolean | undefined, parLevelMedications?: (number | unknown) | undefined, parLevelVaccines?: (number | unknown) | undefined, parLevelSupplies?: (number | unknown) | undefined, parLevelFood?: (number | unknown) | undefined, valuationMethod?: string | undefined, defaultVendor?: (string | null) | undefined, preferredShippingMethod?: string | undefined, vendorAccountId?: (string | null) | undefined, backorderSubstitutionsEnabled?: boolean | undefined, vetcoveEnabled?: boolean | undefined, vetcoveApiKey?: (string | null) | undefined, vetcoveApiKeyConfigured?: boolean | undefined, vetcoveApiKeyArn?: (string | null) | undefined, covetrusEnabled?: boolean | undefined, covetrusApiKey?: (string | null) | undefined, covetrusApiKeyConfigured?: boolean | undefined, covetrusApiKeyArn?: (string | null) | undefined, transmissionMethod?: string | undefined, defaultOnlinePharmacy?: string | undefined, clientPharmacyOverridesAllowed?: boolean | undefined, defaultDispenseFee?: (number | unknown) | undefined, defaultDispenseUnit?: string | undefined, genericSubstitutionAllowed?: boolean | undefined, showDispenseFeesSeparately?: boolean | undefined, labelBranding?: (string | null) | undefined, multiLanguageLabelsEnabled?: boolean | undefined, autoLogDeaRegister?: boolean | undefined, mfaForControlledRx?: boolean | undefined, barcodeScanBeforeDispense?: boolean | undefined, refrigeratedMedSensors?: boolean | undefined, enforceVcprCheck?: boolean | undefined, vcprRequiredDays?: (number | unknown) | undefined, maxDispenseQuantity?: (number | unknown) | undefined, negativeInventoryMode?: (string | null) | undefined, overdraftSettlementMode?: (string | null) | undefined, allowAppointmentDispenseWithoutWitness?: (boolean | null) | undefined, automatedCountsEnabled?: boolean | undefined, countFrequency?: string | undefined, salesVelocityReportEnabled?: boolean | undefined}; export type PatchApiClinicConfigInventoryArgs = {body: InventorySettingsDto}; export type PatchApiClinicConfigInventoryOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const inventorySettingsDto = z.object({defaultItemMarkup: z.union([z.number(), z.string()]).optional(), expiryTrackingEnabled: z.boolean().optional(), parLevelMedications: z.union([z.number().int(), z.string()]).optional(), parLevelVaccines: z.union([z.number().int(), z.string()]).optional(), parLevelSupplies: z.union([z.number().int(), z.string()]).optional(), parLevelFood: z.union([z.number().int(), z.string()]).optional(), valuationMethod: z.string().optional(), defaultVendor: z.string().nullable().optional(), preferredShippingMethod: z.string().optional(), vendorAccountId: z.string().nullable().optional(), backorderSubstitutionsEnabled: z.boolean().optional(), vetcoveEnabled: z.boolean().optional(), vetcoveApiKey: z.string().nullable().optional(), vetcoveApiKeyConfigured: z.boolean().optional(), vetcoveApiKeyArn: z.string().nullable().optional(), covetrusEnabled: z.boolean().optional(), covetrusApiKey: z.string().nullable().optional(), covetrusApiKeyConfigured: z.boolean().optional(), covetrusApiKeyArn: z.string().nullable().optional(), transmissionMethod: z.string().optional(), defaultOnlinePharmacy: z.string().optional(), clientPharmacyOverridesAllowed: z.boolean().optional(), defaultDispenseFee: z.union([z.number(), z.string()]).optional(), defaultDispenseUnit: z.string().optional(), genericSubstitutionAllowed: z.boolean().optional(), showDispenseFeesSeparately: z.boolean().optional(), labelBranding: z.string().nullable().optional(), multiLanguageLabelsEnabled: z.boolean().optional(), autoLogDeaRegister: z.boolean().optional(), mfaForControlledRx: z.boolean().optional(), barcodeScanBeforeDispense: z.boolean().optional(), refrigeratedMedSensors: z.boolean().optional(), enforceVcprCheck: z.boolean().optional(), vcprRequiredDays: z.union([z.number().int(), z.string()]).optional(), maxDispenseQuantity: z.union([z.number(), z.string()]).optional(), negativeInventoryMode: z.string().nullable().optional(), overdraftSettlementMode: z.string().nullable().optional(), allowAppointmentDispenseWithoutWitness: z.boolean().nullable().optional(), automatedCountsEnabled: z.boolean().optional(), countFrequency: z.string().optional(), salesVelocityReportEnabled: z.boolean().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 }; /** * PATCH /clinic-config/inventory - Update inventory settings * * PATCH /clinic-config/inventory */ export const patchApiClinicConfigInventory = async (args: PatchApiClinicConfigInventoryArgs, options?: PatchApiClinicConfigInventoryOptions) => { const {baseUrl = "https://api.clinicos.vet/backend/business", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/clinic-config/inventory${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(inventorySettingsDto, await res.json()) };