export type CreateApiNewsNewsIdUpdatesArgs = {news_id: number, body: BodyInit}; export type CreateApiNewsNewsIdUpdatesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a news article update * * POST /news/{news_id}/updates */ export const createApiNewsNewsIdUpdates = async (args: CreateApiNewsNewsIdUpdatesArgs, options?: CreateApiNewsNewsIdUpdatesOptions) => { const {baseUrl = "https://www.rcac.purdue.edu/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "*/*") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/news/${encodeURIComponent(String(args.news_id))}/updates${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };