export type CollectionFeaturedProduct = {x?: number | undefined, y?: number | undefined, offerId?: string | undefined}; export type Collection = {headline?: Array | undefined, customLabel4?: string | undefined, customLabel2?: string | undefined, imageLink?: Array | undefined, customLabel1?: string | undefined, customLabel0?: string | undefined, mobileLink?: string | undefined, featuredProduct?: Array | undefined, link?: string | undefined, id?: string | undefined, productCountry?: string | undefined, customLabel3?: string | undefined, language?: string | undefined}; export type CreateApiMerchantIdCollectionsArgs = {merchantId: string, body: Collection}; export type CreateApiMerchantIdCollectionsOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; /** * Uploads a collection to your Merchant Center account. If a collection with the same collectionId already exists, this method updates that entry. In each update, the collection is completely replaced by the fields in the body of the update request. * * POST /{merchantId}/collections */ export const createApiMerchantIdCollections = async (args: CreateApiMerchantIdCollectionsArgs, options?: CreateApiMerchantIdCollectionsOptions) => { 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))}/collections${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() };