export type GetApiApiV1CorporateActionArgs = {symbol: string, startTime?: number | undefined, endTime?: number | undefined, types?: (Array<'reverse_splits' | 'forward_splits' | 'unit_splits' | 'stock_dividends' | 'cash_dividends'>) | undefined}; export type GetApiApiV1CorporateActionOptions = {baseUrl?: string | undefined, TradingApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get stock corporate-action list * * GET /api/v1/corporate-action * * Also accepts auth: TradingApiNonce, TradingApiTimestamp, TradingApiSignature, ApiChainId, ApiProductType */ export const getApiApiV1CorporateAction = async (args: GetApiApiV1CorporateActionArgs, options?: GetApiApiV1CorporateActionOptions) => { const {baseUrl = "https://rwa-api.anchored.finance/rwa/trading", fetch: fetchFn = fetch, TradingApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.symbol != null) query.append("symbol", String(args.symbol)) if (args.startTime != null) query.append("startTime", String(args.startTime)) if (args.endTime != null) query.append("endTime", String(args.endTime)) for (const item of args.types ?? []) query.append("types", String(item)) if (TradingApiKey !== undefined) headers.set("x-api-key", TradingApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/corporate-action${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.blob() };