export type DeleteApiApiV5AdminChallengesArgs = {challenge_id: number}; export type DeleteApiApiV5AdminChallengesOptions = {baseUrl?: string | undefined, RWAPIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete challenge * * DELETE /api/v5/admin/challenges/ */ export const deleteApiApiV5AdminChallenges = async (args: DeleteApiApiV5AdminChallengesArgs, options?: DeleteApiApiV5AdminChallengesOptions) => { const {baseUrl = "https://api.pavlok.com", fetch: fetchFn = fetch, RWAPIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.challenge_id != null) query.append("challenge_id", String(args.challenge_id)) if (RWAPIKeyHeader !== undefined) headers.set("Authorization", RWAPIKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/api/v5/admin/challenges/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };