import { IGraphToken } from "../../@types/intellisense/graph" ; import { IGraph } from "../../@types/lib/graph" ; import { Base , Request , RequestType } from "../utils" ; /**
 * Graph
 */ export const Graph = ( ( accessToken , version ? ) => { let graph = new Base ( { accessToken } ) ; graph . targetInfo . endpoint = version || "v1.0" ; graph . targetInfo . requestType = RequestType . GraphGet ; Request . addMethods ( graph , { __metadata : { type : "graph" } } ) ; return graph ; } ) as any ; Graph . getAccessToken = ( scope ? ) : Promise < IGraphToken > => { return new Promise ( ( resolve , reject ) => { let data = { "resource" : "https://graph.microsoft.com" } ; scope ? data [ "scope" ] = scope : null ; ( new Base ( { endpoint : "SP.OAuth.Token/Acquire" , data , method : "POST" } ) ) . execute ( token => { resolve ( token ) ; } ) ; } ) ; } ;