import { request , IRequestOptions } from "@esri/arcgis-rest-request" ; import { IItem } from "@esri/arcgis-rest-types" ; import { getPortalUrl } from "../util/get-portal-url" ; import { isOrgAdmin } from "../sharing/helpers" ; import { IUserRequestOptions } from "@esri/arcgis-rest-auth" ; interface IReassignItemOptions extends IUserRequestOptions { id : string ; currentOwner : string ; targetUsername : string ; targetFolderName ? : string ; } interface IReassignItemResponse { success : boolean ; itemId : string ; } param reassignOptions export function reassignItem ( reassignOptions ) { return isOrgAdmin ( reassignOptions ) . then ( isAdmin => { if ( ! isAdmin ) { throw Error ( `Item ${ reassignOptions . id } can not be reassigned because current user is not an organization administrator.` ) ; } const url = `${ getPortalUrl ( reassignOptions ) }/content/users/${ reassignOptions . currentOwner }/items/${ reassignOptions . id }/reassign` ; const opts = { params : { targetUsername : reassignOptions . targetUsername , targetFolderName : reassignOptions . targetFolderName } , authentication : reassignOptions . authentication } ; return request ( url , opts ) ; } ) ; }