export type GetApiChannelsChannelIdArgs = {channel_id: string}; export type GetApiChannelsChannelIdOptions = {baseUrl: string, apikeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * get channel * * GET /channels/{channel_id} */ export const getApiChannelsChannelId = async (args: GetApiChannelsChannelIdArgs, options: GetApiChannelsChannelIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, apikeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (apikeyAuth !== undefined) headers.set('authorization', `apikey ${apikeyAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/channels/${encodeURIComponent(String(args.channel_id))}${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.text() };