export type CreateApiStorageGroupIconArgs = {userGroupId: number, body: BodyInit}; export type CreateApiStorageGroupIconOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Uploads role's(group) icon by provided user role(group) ID * * POST /storage/groupIcon */ export const createApiStorageGroupIcon = async (args: CreateApiStorageGroupIconArgs, options?: CreateApiStorageGroupIconOptions) => { const {baseUrl = "http://localhost:9090", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.userGroupId != null) query.append("userGroupId", String(args.userGroupId)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/storage/groupIcon${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 undefined };