export type GetApiAvatarsViewAvatarIdAvatarFormatArgs = {avatarId: string, avatarFormat: 'medium.jpg' | 'small.jpg'}; export type GetApiAvatarsViewAvatarIdAvatarFormatOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get an avatar as an image. * * GET /avatars/view/{avatarId}/{avatarFormat} */ export const getApiAvatarsViewAvatarIdAvatarFormat = async (args: GetApiAvatarsViewAvatarIdAvatarFormatArgs, options?: GetApiAvatarsViewAvatarIdAvatarFormatOptions) => { const {baseUrl = "https://passbolt.local", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/jpeg") const url = `${baseUrl.replace(/\/+$/, '')}/avatars/view/${encodeURIComponent(String(args.avatarId))}/${encodeURIComponent(String(args.avatarFormat))}${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 res.blob() };