export type BadgeTagDto = {id: string, name: string}; export type BadgeAuthorDto = {name: string, uri: string}; export type UpdateBadgeDto = {status?: ('draft' | 'under_review' | 'approved' | 'rejected' | 'live') | undefined, title?: string | undefined, image?: string | undefined, type?: ('achievement' | 'attendance') | undefined, description?: string | undefined, chainId?: string | undefined, contract?: string | undefined, claimEndDate?: string | undefined, maxClaims?: number | undefined, tags?: Array | undefined, author?: BadgeAuthorDto | undefined}; export type PatchApiCommunityIdBadgeBadgeIdArgs = {id: string, badgeId: string, body: UpdateBadgeDto}; export type PatchApiCommunityIdBadgeBadgeIdOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update badge * * PATCH /community/{id}/badge/{badgeId} */ export const patchApiCommunityIdBadgeBadgeId = async (args: PatchApiCommunityIdBadgeBadgeIdArgs, options?: PatchApiCommunityIdBadgeBadgeIdOptions) => { const {baseUrl = "https://api.openpage.fun/v1", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set("X-Api-Key", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/community/${encodeURIComponent(String(args.id))}/badge/${encodeURIComponent(String(args.badgeId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };