import { request , IRequestOptions , appendCustomParams } from "@esri/arcgis-rest-request" ; import { IPagingParams , IGroup , IItem , IUser } from "@esri/arcgis-rest-types" ; import { getPortalUrl } from "../util/get-portal-url" ; export interface IGroupCategorySchema { categorySchema : IGroupCategory [ ] ; } export interface IGroupCategory { title : string ; description ? : string ; categories ? : IGroupCategory [ ] ; } export interface IGetGroupContentOptions extends IRequestOptions { paging : IPagingParams ; } export interface IGroupContentResult { total : number ; start : number ; num : number ; nextStart : number ; items : IItem [ ] ; } export interface IGroupUsersResult { owner : string ; admins : string [ ] ; users : string [ ] ; } param id param requestOptions returns export function getGroup ( id , requestOptions ? ) { const url = `${ getPortalUrl ( requestOptions ) }/community/groups/${ id }` ; const options = { ... { httpMethod : "GET" } , ... requestOptions } ; return request ( url , options ) ; } param id param requestOptions returns see https export function getGroupCategorySchema ( id , requestOptions ? ) { const url = `${ getPortalUrl ( requestOptions ) }/community/groups/${ id }/categorySchema` ; const options = { ... { httpMethod : "GET" } , ... requestOptions } ; return request ( url , options ) ; } param id param requestOptions returns export function getGroupContent ( id , requestOptions ? ) { const url = `${ getPortalUrl ( requestOptions ) }/content/groups/${ id }` ; const options = { ... { httpMethod : "GET" } , params : { start : 1 , num : 100 } , ... requestOptions } as IGetGroupContentOptions ; if ( requestOptions && requestOptions . paging ) { options . params = { ... requestOptions . paging } ; } return request ( url , options ) ; } param id param requestOptions returns export function getGroupUsers ( id , requestOptions ? ) { const url = `${ getPortalUrl ( requestOptions ) }/community/groups/${ id }/users` ; const options = { ... { httpMethod : "GET" } , ... requestOptions } ; return request ( url , options ) ; } export interface ISearchGroupUsersOptions extends IRequestOptions , IPagingParams { name ? : string ; sortField ? : string ; sortOrder ? : string ; joined ? : number | number [ ] ; memberType ? : string ; [ key ] : any ; } export interface ISearchGroupUsersResult { total : number ; start : number ; num : number ; nextStart : number ; owner : IUser ; users : any [ ] ; } param id param searchOptions returns export function searchGroupUsers ( id , searchOptions ? ) { const url = `${ getPortalUrl ( searchOptions ) }/community/groups/${ id }/userlist` ; const options = appendCustomParams < ISearchGroupUsersOptions > ( searchOptions || { } , [ "name" , "num" , "start" , "sortField" , "sortOrder" , "joined" , "memberType" ] , { httpMethod : "GET" } ) ; return request ( url , options ) ; }