export type PatchApiDamFoldersFolderIdFilesFileIdArgs = {folder_id: string, file_id: string, body: {data: {type?: string | undefined, id?: string | undefined, attributes?: ({name?: string | undefined}) | undefined}}}; export type PatchApiDamFoldersFolderIdFilesFileIdOptions = {baseUrl: string, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update a file * * PATCH /dam/folders/{folder_id}/files/{file_id} */ export const patchApiDamFoldersFolderIdFilesFileId = async (args: PatchApiDamFoldersFolderIdFilesFileIdArgs, options: PatchApiDamFoldersFolderIdFilesFileIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/vnd.api+json") headers.set('accept', "multipart/form-data") if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/dam/folders/${encodeURIComponent(String(args.folder_id))}/files/${encodeURIComponent(String(args.file_id))}${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 res.blob() };