export type MoveMediaDTO = {assetIds: Array, folderId?: (string | null) | undefined}; export type CreateApiApiV1MediaMoveArgs = {body: MoveMediaDTO}; export type CreateApiApiV1MediaMoveOptions = {baseUrl: string, OAuth2PasswordBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Move assets to a folder * * POST /api/v1/media/move */ export const createApiApiV1MediaMove = async (args: CreateApiApiV1MediaMoveArgs, options: CreateApiApiV1MediaMoveOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth2PasswordBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (OAuth2PasswordBearer !== undefined) headers.set('authorization', `Bearer ${OAuth2PasswordBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/media/move${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };