export type GetApiApiCampaignArgs = {status?: number | undefined, showDeleted?: boolean | undefined}; export type GetApiApiCampaignOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * GET /api/Campaign */ export const getApiApiCampaign = async (args: GetApiApiCampaignArgs, options: GetApiApiCampaignOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.status != null) query.append("status", String(args.status)) if (args.showDeleted != null) query.append("showDeleted", String(args.showDeleted)) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/Campaign${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 };