export type CreateApiCrmV1EntitiesEntityItemIdUploadAvatarArgs = {body: BodyInit}; export type CreateApiCrmV1EntitiesEntityItemIdUploadAvatarOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upload entity avatar * * POST /crm/v1/entities/{entity}/{itemId}/upload_avatar */ export const createApiCrmV1EntitiesEntityItemIdUploadAvatar = async (args: CreateApiCrmV1EntitiesEntityItemIdUploadAvatarArgs, options: CreateApiCrmV1EntitiesEntityItemIdUploadAvatarOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/crm/v1/entities/${encodeURIComponent(String(args.entity))}/${encodeURIComponent(String(args.itemId))}/upload_avatar${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 };