lib/api-client.js
function(args) {
    var baseUrl = this.baseUrl + this.basePath;
    var authToken = this.authToken;
    var qs = this._buildQueryString(args.params);

    return new Promise(function(resolve, reject) {
      var req = new XMLHttpRequest();

      req.onreadystatechange = function() {
        if (req.readyState === 4) {
          try {
            var response = JSON.parse(req.responseText);
            var status = req.status;

            if (status >= 200 && status < 400) {
              return resolve(
                addShadowProperty({
                  target: response,
                  property: 'httpRequest',
                  value: req
                })
              );
            }

            return reject(
              createApiError(
                merge(response, {
                  status: status,
                  httpRequest: req
                })
              )
            );
          } catch (err) {
            reject(err);
          }
        }
      };

      req.open(args.method, baseUrl + args.path + qs, true);
      req.setRequestHeader('Authorization', 'Bearer ' + authToken);
      req.setRequestHeader('Accept', 'application/json');
      req.setRequestHeader('Content-type', 'application/json; charset=utf-8');
      req.send(args.payload ? JSON.stringify(args.payload) : null);
    });
  }
function(args) {
    var baseUrl = this.baseUrl + this.basePath;
    var authToken = this.authToken;
    var qs = this._buildQueryString(args.params);

    return new Promise(function(resolve, reject) {
      var req = new XMLHttpRequest();

      req.onreadystatechange = function() {
        if (req.readyState === 4) {
          try {
            var response = JSON.parse(req.responseText);
            var status = req.status;

            if (status >= 200 && status < 400) {
              return resolve(
                addShadowProperty({
                  target: response,
                  property: 'httpRequest',
                  value: req
                })
              );
            }

            return reject(
              createApiError(
                merge(response, {
                  status: status,
                  httpRequest: req
                })
              )
            );
          } catch (err) {
            reject(err);
          }
        }
      };

      req.open(args.method, baseUrl + args.path + qs, true);
      req.setRequestHeader('Authorization', 'Bearer ' + authToken);
      req.setRequestHeader('Accept', 'application/json');
      req.setRequestHeader('Content-type', 'application/json; charset=utf-8');
      req.send(args.payload ? JSON.stringify(args.payload) : null);
    });
  }
function ( args ) { var baseUrl = this . baseUrl + this . basePath ; var authToken = this . authToken ; var qs = this . _buildQueryString ( args . params ) ; return new Promise ( function ( resolve , reject ) { var req = new XMLHttpRequest ( ) ; req . onreadystatechange = function ( ) { if ( req . readyState === 4 ) { try { var response = JSON . parse ( req . responseText ) ; var status = req . status ; if ( status >= 200 && status < 400 ) { return resolve ( addShadowProperty ( { target : response , property : 'httpRequest' , value : req } ) ) ; } return reject ( createApiError ( merge ( response , { status : status , httpRequest : req } ) ) ) ; } catch ( err ) { reject ( err ) ; } } } ; req . open ( args . method , baseUrl + args . path + qs , true ) ; req . setRequestHeader ( 'Authorization' , 'Bearer ' + authToken ) ; req . setRequestHeader ( 'Accept' , 'application/json' ) ; req . setRequestHeader ( 'Content-type' , 'application/json; charset=utf-8' ) ; req . send ( args . payload ? JSON . stringify ( args . payload ) : null ) ; } ) ; }
Generic request method.

@param args.method
@param args.path
@returns {Promise}
@private
Generic request method .