export type ConnectLocationDto = {location_id: string}; export type CreateApiStreamDspV1LocationsConnectionArgs = {Authorization?: string | undefined, body: ConnectLocationDto}; export type CreateApiStreamDspV1LocationsConnectionOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Connect Location (Stream –> DSP via OAuth) * * POST /stream-dsp/v1/locations/connection */ export const createApiStreamDspV1LocationsConnection = async (args: CreateApiStreamDspV1LocationsConnectionArgs, options: CreateApiStreamDspV1LocationsConnectionOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) const url = `${baseUrl.replace(/\/+$/, '')}/stream-dsp/v1/locations/connection${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 };