export type PosStore = {storeName?: string | undefined, websiteUrl?: string | undefined, gcidCategory?: Array | undefined, matchingStatus?: string | undefined, placeId?: string | undefined, storeAddress?: string | undefined, kind?: string | undefined, matchingStatusHint?: string | undefined, storeCode?: string | undefined, phoneNumber?: string | undefined}; export type Price = {value?: string | undefined, currency?: string | undefined}; export type PosInventory = {price?: Price | undefined, timestamp?: string | undefined, targetCountry?: string | undefined, kind?: string | undefined, quantity?: unknown | undefined, contentLanguage?: string | undefined, pickupSla?: string | undefined, itemId?: string | undefined, pickupMethod?: string | undefined, storeCode?: string | undefined, gtin?: string | undefined}; export type PosSale = {contentLanguage?: string | undefined, kind?: string | undefined, quantity?: unknown | undefined, targetCountry?: string | undefined, price?: Price | undefined, timestamp?: string | undefined, gtin?: string | undefined, saleId?: string | undefined, storeCode?: string | undefined, itemId?: string | undefined}; export type PosCustomBatchRequestEntry = {targetMerchantId?: unknown | undefined, method?: string | undefined, merchantId?: unknown | undefined, storeCode?: string | undefined, store?: PosStore | undefined, inventory?: PosInventory | undefined, sale?: PosSale | undefined, batchId?: number | undefined}; export type PosCustomBatchRequest = {entries?: Array | undefined}; export type CreateApiPosBatchArgs = {body: PosCustomBatchRequest}; export type CreateApiPosBatchOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; /** * Batches multiple POS-related calls in a single request. * * POST /pos/batch */ export const createApiPosBatch = async (args: CreateApiPosBatchArgs, options?: CreateApiPosBatchOptions) => { 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(/\/+$/, '')}/pos/batch${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() };