export type InventoryQuantityExpression = {quantity?: number | undefined, variantId?: string | undefined}; export type CreateInventoryAdjustmentRequest = {decrementOperations?: Array | undefined, incrementOperations?: Array | undefined, setFiniteOperations?: Array | undefined, setUnlimitedOperations?: Array | undefined}; export type CreateApi10CommerceInventoryAdjustmentsArgs = {'Idempotency-Key': string, Authorization: string, 'User-Agent': string, body: CreateInventoryAdjustmentRequest}; export type CreateApi10CommerceInventoryAdjustmentsOptions = {baseUrl?: string | undefined, Authorization?: string | undefined, fetch?: typeof fetch | undefined}; /** * Adjust stock quantities * * POST /1.0/commerce/inventory/adjustments */ export const createApi10CommerceInventoryAdjustments = async (args: CreateApi10CommerceInventoryAdjustmentsArgs, options?: CreateApi10CommerceInventoryAdjustmentsOptions) => { const {baseUrl = "https://api.squarespace.com", fetch: fetchFn = fetch, Authorization} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Idempotency-Key'] != null) headers.set("Idempotency-Key", String(args['Idempotency-Key'])) if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args['User-Agent'] != null) headers.set("User-Agent", String(args['User-Agent'])) if (Authorization !== undefined) headers.set('authorization', `Bearer ${Authorization}`) const url = `${baseUrl.replace(/\/+$/, '')}/1.0/commerce/inventory/adjustments${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };