export type AttributionSettingsConversionType = {name?: string | undefined, includeInReporting?: boolean | undefined}; export type AttributionSettings = {conversionType?: Array | undefined, attributionLookbackWindowInDays?: number | undefined, attributionModel?: ('ATTRIBUTION_MODEL_UNSPECIFIED' | 'CROSS_CHANNEL_LAST_CLICK' | 'ADS_PREFERRED_LAST_CLICK' | 'CROSS_CHANNEL_DATA_DRIVEN' | 'CROSS_CHANNEL_FIRST_CLICK' | 'CROSS_CHANNEL_LINEAR' | 'CROSS_CHANNEL_POSITION_BASED' | 'CROSS_CHANNEL_TIME_DECAY') | undefined}; export type MerchantCenterDestination = {destinationId?: string | undefined, displayName?: string | undefined, attributionSettings?: AttributionSettings | undefined, currencyCode?: string | undefined}; export type GoogleAnalyticsLink = {attributionSettings?: AttributionSettings | undefined, propertyName?: string | undefined, propertyId?: unknown | undefined}; export type ConversionSource = {conversionSourceId?: string | undefined, state?: ('STATE_UNSPECIFIED' | 'ACTIVE' | 'ARCHIVED' | 'PENDING') | undefined, merchantCenterDestination?: MerchantCenterDestination | undefined, googleAnalyticsLink?: GoogleAnalyticsLink | undefined, expireTime?: unknown | undefined}; export type CreateApiMerchantIdConversionsourcesArgs = {merchantId: string, body: ConversionSource}; export type CreateApiMerchantIdConversionsourcesOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; /** * Creates a new conversion source. * * POST /{merchantId}/conversionsources */ export const createApiMerchantIdConversionsources = async (args: CreateApiMerchantIdConversionsourcesArgs, options?: CreateApiMerchantIdConversionsourcesOptions) => { 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))}/conversionsources${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() };