@@ -110,10 +110,7 @@ export class Api {
110110 * @return {Promise } A promise which will resolved with API key if everything went ok and rejected otherwise
111111 */
112112 getApiKey ( username : string , password : string ) : Promise < string > {
113- if ( this . _uriGenerationMode ) {
114- throw new Error ( 'This method is not supported in batch mode' )
115- }
116- return new Promise ( ( resolve , reject ) => {
113+ return new Promise ( ( resolve , reject ) => {
117114 if ( typeof this . _httpOptions . headers . apiKey !== 'undefined' ) {
118115 resolve ( this . _httpOptions . headers . apiKey )
119116 }
@@ -188,10 +185,7 @@ export class Api {
188185 * @return {Promise } A promise which will resolved if everything went ok and rejected otherwise
189186 */
190187 clearApiKey ( ) {
191- if ( this . _uriGenerationMode ) {
192- throw new Error ( 'This method is not supported in batch mode' )
193- }
194- return new Promise ( ( resolve , reject ) => {
188+ return new Promise ( ( resolve , reject ) => {
195189 const req = this . execute ( 'USER' , null , 'clearApiKey' ) as Promise < any >
196190 req . then ( ( result ) => {
197191 if ( result ) {
@@ -307,9 +301,6 @@ export class Api {
307301 * @return {Promise } A promise which will resolved with logged in user data if everything went ok and rejected otherwise
308302 */
309303 login ( username : string , password : string ) {
310- if ( this . _uriGenerationMode ) {
311- throw new Error ( 'This method is not supported in batch mode' )
312- }
313304 const req = this . request ( 'login' , { username : username , password : password } , null , Api . Methods . POST )
314305 return ( req as Promise < any > ) . then ( ( data ) => {
315306 this . setSessionID ( data . sessionID )
@@ -323,10 +314,7 @@ export class Api {
323314 * @return {Promise } A promise which will resolved if everything went ok and rejected otherwise
324315 */
325316 logout ( ) : Promise < undefined > {
326- if ( this . _uriGenerationMode ) {
327- throw new Error ( 'This method is not supported in batch mode' )
328- }
329- return new Promise ( ( resolve , reject ) => {
317+ return new Promise ( ( resolve , reject ) => {
330318 const req = this . request ( 'logout' , null , null , Api . Methods . GET ) ;
331319 ( req as Promise < any > ) . then ( ( result ) => {
332320 if ( result && result . success ) {
@@ -512,9 +500,6 @@ export class Api {
512500 search ( objCode : string , query ?: object , fields ?: TFields , useHttpPost = false ) {
513501 let searchQuery , method
514502 if ( useHttpPost ) {
515- if ( this . _uriGenerationMode ) {
516- throw new Error ( 'Using useHttpPost=true is not supported in batch mode for this method' )
517- }
518503 searchQuery = objectAssign ( { } , query , { method : Api . Methods . GET } )
519504 method = Api . Methods . POST
520505 }
@@ -543,9 +528,6 @@ export class Api {
543528 batch ( uriCollector : ( batchApi : IBatchApi ) => string [ ] , isAtomic ?: false ) : Promise < any [ ] >
544529 batch ( uriCollector : ( batchApi : IBatchApi ) => string [ ] , isAtomic ?: true ) : Promise < undefined >
545530 batch ( uriCollector : ( batchApi : IBatchApi ) => string [ ] , isAtomic ?: boolean ) : Promise < any [ ] | undefined > {
546- if ( this . _uriGenerationMode ) {
547- throw new Error ( 'This method is not supported in batch mode' )
548- }
549531 const batchApi = batchApiFactory ( this )
550532 const uris = uriCollector ( batchApi )
551533 if ( uris . length === 0 ) {
@@ -574,9 +556,6 @@ export class Api {
574556 * @return {string } returns the given api key value
575557 */
576558 setApiKey ( apiKey ) {
577- if ( this . _uriGenerationMode ) {
578- throw new Error ( 'This method is not supported in batch mode' )
579- }
580559 return this . _httpOptions . headers . apiKey = apiKey
581560 }
582561
@@ -586,10 +565,7 @@ export class Api {
586565 * @param {String|undefined } sessionID sessionID to set
587566 */
588567 setSessionID ( sessionID ) {
589- if ( this . _uriGenerationMode ) {
590- throw new Error ( 'This method is not supported in batch mode' )
591- }
592- if ( sessionID ) {
568+ if ( sessionID ) {
593569 this . _httpOptions . headers . sessionID = sessionID
594570 }
595571 else {
@@ -603,10 +579,7 @@ export class Api {
603579 * @param {String|undefined } xsrfToken X-XSRF-TOKEN to set
604580 */
605581 setXSRFToken ( xsrfToken ?: string ) {
606- if ( this . _uriGenerationMode ) {
607- throw new Error ( 'This method is not supported in batch mode' )
608- }
609- if ( xsrfToken ) {
582+ if ( xsrfToken ) {
610583 this . _httpOptions . headers [ 'X-XSRF-TOKEN' ] = xsrfToken
611584 }
612585 else {
@@ -626,19 +599,13 @@ export class Api {
626599 * @param {String } filename Override the filename
627600 */
628601 uploadFromStream ( stream : Readable , filename : string ) {
629- if ( this . _uriGenerationMode ) {
630- throw new Error ( 'This method is not supported in batch mode' )
631- }
632- const data = new NodeFormData ( )
602+ const data = new NodeFormData ( )
633603 data . append ( 'uploadedFile' , stream , filename )
634604 return this . request ( 'upload' , data , null , Api . Methods . POST )
635605 }
636606
637607 uploadFileContent ( fileContent , filename : string ) {
638- if ( this . _uriGenerationMode ) {
639- throw new Error ( 'This method is not supported in batch mode' )
640- }
641- const data = new GlobalScope . FormData ( )
608+ const data = new GlobalScope . FormData ( )
642609 data . append ( 'uploadedFile' , fileContent , filename )
643610 return this . request ( 'upload' , data , null , Api . Methods . POST )
644611 }
0 commit comments