import { request , appendCustomParams } from "@esri/arcgis-rest-request" ; import { getPortalUrl } from "../util/get-portal-url" ; import { IUserItemOptions , IRemoveItemResourceOptions , IFolderIdOptions , determineOwner , IManageItemRelationshipOptions } from "./helpers" ; param requestOptions returns export function removeItem ( requestOptions ) { return determineOwner ( requestOptions ) . then ( owner => { const url = `${ getPortalUrl ( requestOptions ) }/content/users/${ owner }/items/${ requestOptions . id }/delete` ; return request ( url , requestOptions ) ; } ) ; } param requestOptions returns export function removeItemRelationship ( requestOptions ) { return determineOwner ( requestOptions ) . then ( owner => { const url = `${ getPortalUrl ( requestOptions ) }/content/users/${ owner }/deleteRelationship` ; const options = appendCustomParams < IManageItemRelationshipOptions > ( requestOptions , [ "originItemId" , "destinationItemId" , "relationshipType" ] , { params : { ... requestOptions . params } } ) ; return request ( url , options ) ; } ) ; } param requestOptions returns export function removeItemResource ( requestOptions ) { return determineOwner ( requestOptions ) . then ( owner => { const url = `${ getPortalUrl ( requestOptions ) }/content/users/${ owner }/items/${ requestOptions . id }/removeResources` ; requestOptions . params = { ... requestOptions . params , resource : requestOptions . resource } ; if ( typeof requestOptions . deleteAll !== "undefined" ) { requestOptions . params . deleteAll = requestOptions . deleteAll ; } return request ( url , requestOptions ) ; } ) ; } param requestOptions returns export function removeFolder ( requestOptions ) { return determineOwner ( requestOptions ) . then ( owner => { const url = `${ getPortalUrl ( requestOptions ) }/content/users/${ encodeURIComponent ( owner ) }/${ requestOptions . folderId }/delete` ; return request ( url , requestOptions ) ; } ) ; }