export type JoinGroupRequestDto = {GroupId?: string | undefined}; export type CreateApiSyncPlayJoinArgs = {body: JoinGroupRequestDto}; export type CreateApiSyncPlayJoinOptions = {baseUrl?: string | undefined, CustomAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Join an existing SyncPlay group. * * POST /SyncPlay/Join */ export const createApiSyncPlayJoin = async (args: CreateApiSyncPlayJoinArgs, options?: CreateApiSyncPlayJoinOptions) => { const {baseUrl = "http://localhost", fetch: fetchFn = fetch, CustomAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (CustomAuthentication !== undefined) headers.set("X-Emby-Authorization", CustomAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/SyncPlay/Join${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 };