export type Price = {value?: string | undefined, currency?: string | undefined}; export type PosInventoryRequest = {contentLanguage?: string | undefined, pickupSla?: string | undefined, price?: Price | undefined, timestamp?: string | undefined, targetCountry?: string | undefined, quantity?: unknown | undefined, gtin?: string | undefined, itemId?: string | undefined, pickupMethod?: string | undefined, storeCode?: string | undefined}; export type CreateApiMerchantIdPosTargetMerchantIdInventoryArgs = {merchantId: string, targetMerchantId: string, body: PosInventoryRequest}; export type CreateApiMerchantIdPosTargetMerchantIdInventoryOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; /** * Submit inventory for the given merchant. * * POST /{merchantId}/pos/{targetMerchantId}/inventory */ export const createApiMerchantIdPosTargetMerchantIdInventory = async (args: CreateApiMerchantIdPosTargetMerchantIdInventoryArgs, options?: CreateApiMerchantIdPosTargetMerchantIdInventoryOptions) => { const {baseUrl = "https://shoppingcontent.googleapis.com/content/v2.1", fetch: fetchFn = fetch, Oauth2, Oauth2c} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (Oauth2 !== undefined) headers.set('authorization', `Bearer ${Oauth2}`) if (Oauth2c !== undefined) headers.set('authorization', `Bearer ${Oauth2c}`) const url = `${baseUrl.replace(/\/+$/, '')}/${encodeURIComponent(String(args.merchantId))}/pos/${encodeURIComponent(String(args.targetMerchantId))}/inventory${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 res.blob() };