export type GetApiV1NewsArgs = {tickers?: string | undefined, category?: ('Earnings' | 'Guidance' | 'M&A' | 'Buyback' | 'Dividend' | 'Leadership' | 'Restructuring' | 'Regulatory' | 'Legal' | 'Cyber' | 'Offering' | 'Bankruptcy' | 'FDA' | 'Insider Trading' | 'News' | 'Other') | undefined, limit?: number | undefined, offset?: number | undefined}; export type GetApiV1NewsOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get latest financial news * * GET /v1/news */ export const getApiV1News = async (args: GetApiV1NewsArgs, options?: GetApiV1NewsOptions) => { const {baseUrl = "https://api.brieftape.com", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.tickers != null) query.append("tickers", String(args.tickers)) if (args.category != null) query.append("category", String(args.category)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/news${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 };