export type AccountCredentials = {purpose?: ('ACCOUNT_CREDENTIALS_PURPOSE_UNSPECIFIED' | 'SHOPIFY_ORDER_MANAGEMENT' | 'SHOPIFY_INTEGRATION') | undefined, expiresIn?: unknown | undefined, accessToken?: string | undefined}; export type CreateApiAccountsAccountIdCredentialsArgs = {accountId: string, body: AccountCredentials}; export type CreateApiAccountsAccountIdCredentialsOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; /** * Uploads credentials for the Merchant Center account. If credentials already exist for this Merchant Center account and purpose, this method updates them. * * POST /accounts/{accountId}/credentials */ export const createApiAccountsAccountIdCredentials = async (args: CreateApiAccountsAccountIdCredentialsArgs, options?: CreateApiAccountsAccountIdCredentialsOptions) => { 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(/\/+$/, '')}/accounts/${encodeURIComponent(String(args.accountId))}/credentials${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() };