export type GetApiApiCiteFormatSlugArgs = {format: 'bibtex' | 'ris' | 'apa' | 'mla' | 'chicago' | 'wikipedia', slug: string}; export type GetApiApiCiteFormatSlugOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Reference-manager export for a finding or the SSRN paper * * GET /api/cite/{format}/{slug} */ export const getApiApiCiteFormatSlug = async (args: GetApiApiCiteFormatSlugArgs, options?: GetApiApiCiteFormatSlugOptions) => { const {baseUrl = "https://signals.gitdealflow.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") const url = `${baseUrl.replace(/\/+$/, '')}/api/cite/${encodeURIComponent(String(args.format))}/${encodeURIComponent(String(args.slug))}${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.text() };