export type GetApiV2TabTabIdEndUserArgs = {tabId: number}; export type GetApiV2TabTabIdEndUserOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieve the requested tab along with any extensions for end-user tabs * * GET /v2/tab/{tabId}/end-user * * Also accepts auth: sessionKey */ export const getApiV2TabTabIdEndUser = async (args: GetApiV2TabTabIdEndUserArgs, options: GetApiV2TabTabIdEndUserOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/tab/${encodeURIComponent(String(args.tabId))}/end-user${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 undefined };