export type SearchRequest = {pageSize?: number | undefined, pageToken?: string | undefined, query?: string | undefined}; export type CreateApiMerchantIdReportsSearchArgs = {merchantId: string, body: SearchRequest}; export type CreateApiMerchantIdReportsSearchOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieves merchant performance metrics matching the search query and optionally segmented by selected dimensions. * * POST /{merchantId}/reports/search */ export const createApiMerchantIdReportsSearch = async (args: CreateApiMerchantIdReportsSearchArgs, options?: CreateApiMerchantIdReportsSearchOptions) => { 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))}/reports/search${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() };