import { IUtility } from "../../@types/lib" ; import * as Types from "../../@types/intellisense" ; import { Base , Request , RequestType } from "../utils" ; /**
 * Utility
 */ export const Utility = ( ( url ? , targetInfo ? ) => { let base = new Base ( targetInfo ) ; let utility = base as any as Types . IUtility ; base . targetInfo . defaultToWebFl = true ; base . targetInfo . endpoint = "SP.Utilities.Utility" ; if ( url ) { base . targetInfo . url = url ; } Request . addMethods ( utility as any , { __metadata : { type : "utility" } } ) ; utility . createWikiPage = ( listUrl , content = "" ) => { let parameters = { ServerRelativeUrl : listUrl , WikiHtmlContent : content } ; return utility . executeMethod ( "createWikiPage" , { argNames : [ "parameters" ] , name : "SP.Utilities.Utility.CreateWikiPageInContextWeb" , replaceEndpointFl : true , requestType : RequestType . PostWithArgsInBody } , [ parameters ] ) ; } ; utility . sendEmail = ( properties ) => { for ( let propName of [ "To" , "CC" , "BCC" ] ) { let propValue = properties [ propName ] ; if ( propValue ) { if ( typeof ( propValue ) === "string" ) { properties [ propName ] = { 'results' : [ propValue ] } ; } else { properties [ propName ] = { 'results' : propValue } ; } } } return utility . executeMethod ( "sendEmail" , { argNames : [ "properties" ] , metadataType : "SP.Utilities.EmailProperties" , name : "SP.Utilities.Utility.sendEmail" , replaceEndpointFl : true , requestType : RequestType . PostWithArgsInBody } , [ properties ] ) ; } ; return utility ; } ) as any as IUtility ;