export type ECommercePlatformLinkInfo = {externalAccountId?: string | undefined}; export type PaymentServiceProviderLinkInfo = {externalAccountId?: string | undefined, externalAccountBusinessCountry?: string | undefined}; export type AccountsLinkRequest = {linkedAccountId?: string | undefined, services?: Array | undefined, linkType?: string | undefined, eCommercePlatformLinkInfo?: ECommercePlatformLinkInfo | undefined, action?: string | undefined, paymentServiceProviderLinkInfo?: PaymentServiceProviderLinkInfo | undefined}; export type CreateApiMerchantIdAccountsAccountIdLinkArgs = {merchantId: string, accountId: string, body: AccountsLinkRequest}; export type CreateApiMerchantIdAccountsAccountIdLinkOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; /** * Performs an action on a link between two Merchant Center accounts, namely accountId and linkedAccountId. * * POST /{merchantId}/accounts/{accountId}/link */ export const createApiMerchantIdAccountsAccountIdLink = async (args: CreateApiMerchantIdAccountsAccountIdLinkArgs, options?: CreateApiMerchantIdAccountsAccountIdLinkOptions) => { 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))}/accounts/${encodeURIComponent(String(args.accountId))}/link${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() };