@@ -35,6 +35,10 @@ import bearm = require('./handlers/bearertoken');
3535import ntlmm = require( './handlers/ntlm' ) ;
3636import patm = require( './handlers/personalaccesstoken' ) ;
3737
38+ import * as rm from 'typed-rest-client/RestClient' ;
39+ //import * as hm from 'typed-rest-client/HttpClient';
40+ import vsom = require( './VsoClient' ) ;
41+
3842/**
3943 * Methods to return handler objects (see handlers folder)
4044 */
@@ -64,6 +68,8 @@ export class WebApi {
6468
6569 serverUrl : string ;
6670 authHandler : VsoBaseInterfaces . IRequestHandler ;
71+ rest : rm . RestClient ;
72+ vsoClient : vsom . VsoClient ;
6773
6874 /*
6975 * Factory to return client apis and handlers
@@ -73,6 +79,8 @@ export class WebApi {
7379 constructor ( defaultUrl : string , authHandler : VsoBaseInterfaces . IRequestHandler ) {
7480 this . serverUrl = defaultUrl ;
7581 this . authHandler = authHandler ;
82+ this . rest = new rm . RestClient ( 'vsts-node-api' , null , [ this . authHandler ] ) ;
83+ this . vsoClient = new vsom . VsoClient ( defaultUrl , this . rest ) ;
7684 }
7785
7886 /**
@@ -85,6 +93,18 @@ export class WebApi {
8593 return new this ( defaultUrl , bearerHandler ) ;
8694 }
8795
96+ public async connect ( ) : Promise < any > {
97+ return new Promise ( async ( resolve , reject ) => {
98+ try {
99+ let res : rm . IRestResponse < any > = await this . rest . get < any > ( this . vsoClient . resolveUrl ( '/_apis/connectionData' ) ) ;
100+ resolve ( res . result ) ;
101+ }
102+ catch ( err ) {
103+ reject ( err ) ;
104+ }
105+ } ) ;
106+ }
107+
88108 /**
89109 * Each factory method can take a serverUrl and a list of handlers
90110 * if these aren't provided, the default url and auth handler given to the constructor for this class will be used
0 commit comments