export type ChangeItemUnitOfMeasureRequest = {inventoryUnit?: (string | null) | undefined, acknowledgeNoRecalculation?: boolean | undefined}; export type PatchApiV1ItemsItemIdUnitOfMeasureArgs = {itemId: number, Account: unknown, body: ChangeItemUnitOfMeasureRequest}; export type PatchApiV1ItemsItemIdUnitOfMeasureOptions = {baseUrl: string, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Change an item's inventory (base) unit. Requires `AcknowledgeNoRecalculation = true`: * existing transactions and stock levels are NOT recalculated. The change is rejected if the * required unit conversions do not exist for the new unit. * * PATCH /v1/Items/{itemId}/unit-of-measure */ export const patchApiV1ItemsItemIdUnitOfMeasure = async (args: PatchApiV1ItemsItemIdUnitOfMeasureArgs, options: PatchApiV1ItemsItemIdUnitOfMeasureOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json-patch+json; x-api-version=1.0") if (args.Account != null) query.append("Account", String(args.Account)) if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/Items/${encodeURIComponent(String(args.itemId))}/unit-of-measure${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 undefined };