export type GetApiWsPrivateOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, TimestampAuth?: string | undefined, SignatureAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Private WebSocket * * GET /ws/private */ export const getApiWsPrivate = async (options?: GetApiWsPrivateOptions) => { const {baseUrl = "https://api.altcointrader.co.za", fetch: fetchFn = fetch, ApiKeyAuth, TimestampAuth, SignatureAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (ApiKeyAuth !== undefined) headers.set("X-API-KEY", ApiKeyAuth) if (TimestampAuth !== undefined) headers.set("X-TIMESTAMP", TimestampAuth) if (SignatureAuth !== undefined) headers.set("X-SIGNATURE", SignatureAuth) const url = `${baseUrl.replace(/\/+$/, '')}/ws/private${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 };