import { Microsoft } from "gd-sprest-def" ; import { ISearch } from "../../@types/lib" ; import { Base , Request , RequestType } from "../utils" ; /**
 * Search
 */ export const Search = ( ( url ? , targetInfo ? ) => { let base = new Base ( targetInfo ) ; let search = base as any as Microsoft . Office . Server . Search . REST . ISearchService ; base . targetInfo . defaultToWebFl = true ; base . targetInfo . endpoint = "search" ; if ( url ) { base . targetInfo . url = url ; } Request . addMethods ( search as any , { __metadata : { type : "Microsoft.Office.Server.Search.REST.SearchService" } } ) ; /** The search query method */ search . searchquery = ( settings ) => { return search . executeMethod ( "query" , { argNames : [ "query" ] , name : "query?[[query]]" , requestType : RequestType . GetReplace } , Search . getQuery ( settings ) ) ; } ; return search ; } ) as any ; Search . getQuery = ( parameters ) => { let query = "" ; for ( let key in parameters ) { query += ( query == "" ? "" : "&" ) + key + "='" + parameters [ key ] + "'" ; } return [ query ] ; } ;