export type GetApiMerchantIdAccountsArgs = {merchantId: string, label?: string | undefined, maxResults?: number | undefined, name?: string | undefined, pageToken?: string | undefined, view?: ('MERCHANT' | 'CSS') | undefined}; export type GetApiMerchantIdAccountsOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; /** * Lists the sub-accounts in your Merchant Center account. * * GET /{merchantId}/accounts */ export const getApiMerchantIdAccounts = async (args: GetApiMerchantIdAccountsArgs, options?: GetApiMerchantIdAccountsOptions) => { 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('accept', "*/*") if (args.label != null) query.append("label", String(args.label)) if (args.maxResults != null) query.append("maxResults", String(args.maxResults)) if (args.name != null) query.append("name", String(args.name)) if (args.pageToken != null) query.append("pageToken", String(args.pageToken)) if (args.view != null) query.append("view", String(args.view)) 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${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };