export type SwitchTenantRequest = {tenant_id: string} | {[key: string]: unknown}; export type CreateApiAuthSwitchTenantArgs = {body: SwitchTenantRequest}; export type CreateApiAuthSwitchTenantOptions = {baseUrl?: string | undefined, FronteggHTTPAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Switch Tenant * * POST /auth/switch-tenant */ export const createApiAuthSwitchTenant = async (args: CreateApiAuthSwitchTenantArgs, options?: CreateApiAuthSwitchTenantOptions) => { const {baseUrl = "https://api.streamkap.com", fetch: fetchFn = fetch, FronteggHTTPAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (FronteggHTTPAuthentication !== undefined) headers.set('authorization', `Bearer ${FronteggHTTPAuthentication}`) const url = `${baseUrl.replace(/\/+$/, '')}/auth/switch-tenant${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 undefined };