adapter.js
function(options) {
    options = options || {};

    // Set default path
    if (!options.url && !options.path) {
      options.path = '';
    }

    // Prepare the request
    var requestOptions = {
      method: options.method || 'GET',
      url: options.url || this.urlRoot + options.path,
      qs: options.qs || {},
      headers: options.headers || {},
    };

    // Add `form`, `body`, or `json` as Request Payload (only one per request)
    //
    // If `json` is a Boolean,
    // Request will set` Content-Type`
    // and call `JSON.stringify()` on `body`
    if (options.body) {
      requestOptions.body = options.body;
      requestOptions.json = _.isBoolean(options.json) ? options.json : true;
    } else if (options.form) {
      requestOptions.form = options.form;
      requestOptions.headers['Content-Type'] =
        'application/x-www-form-urlencoded; charset=utf-8';
    } else if (_.isBoolean(options.json) || _.isObject(options.json)) {
      requestOptions.json = options.json;
    }

    // Basic HTTP Auth
    if (options.auth) {
      requestOptions.auth = options.auth;
    }

    // Access Token
    var accessToken = options.access_token || this.get('access_token');
    if (accessToken) {
      _.defaults(requestOptions.headers, {
        Authorization: ['Bearer', accessToken].join(' ')
      });
    }

    // OAuth Token
    var oauthToken = options.oauth_token || this.get('oauth_token');
    if (oauthToken) {
      _.defaults(requestOptions.headers, {
        Authorization: ['OAuth', oauthToken].join(' ')
      });
    }

    // Authorization Token (No Scheme)
    var authorizationToken = options.authorization_token || this.get('authorization_token');
    if (authorizationToken) {
      _.defaults(requestOptions.headers, {
        Authorization: authorizationToken
      });
    }
    return requestOptions;
  }
function(options) {
    options = options || {};

    // Set default path
    if (!options.url && !options.path) {
      options.path = '';
    }

    // Prepare the request
    var requestOptions = {
      method: options.method || 'GET',
      url: options.url || this.urlRoot + options.path,
      qs: options.qs || {},
      headers: options.headers || {},
    };

    // Add `form`, `body`, or `json` as Request Payload (only one per request)
    //
    // If `json` is a Boolean,
    // Request will set` Content-Type`
    // and call `JSON.stringify()` on `body`
    if (options.body) {
      requestOptions.body = options.body;
      requestOptions.json = _.isBoolean(options.json) ? options.json : true;
    } else if (options.form) {
      requestOptions.form = options.form;
      requestOptions.headers['Content-Type'] =
        'application/x-www-form-urlencoded; charset=utf-8';
    } else if (_.isBoolean(options.json) || _.isObject(options.json)) {
      requestOptions.json = options.json;
    }

    // Basic HTTP Auth
    if (options.auth) {
      requestOptions.auth = options.auth;
    }

    // Access Token
    var accessToken = options.access_token || this.get('access_token');
    if (accessToken) {
      _.defaults(requestOptions.headers, {
        Authorization: ['Bearer', accessToken].join(' ')
      });
    }

    // OAuth Token
    var oauthToken = options.oauth_token || this.get('oauth_token');
    if (oauthToken) {
      _.defaults(requestOptions.headers, {
        Authorization: ['OAuth', oauthToken].join(' ')
      });
    }

    // Authorization Token (No Scheme)
    var authorizationToken = options.authorization_token || this.get('authorization_token');
    if (authorizationToken) {
      _.defaults(requestOptions.headers, {
        Authorization: authorizationToken
      });
    }
    return requestOptions;
  }
function ( options ) { options = options || { } ; // Set default path if ( ! options . url && ! options . path ) { options . path = '' ; } // Prepare the request var requestOptions = { method : options . method || 'GET' , url : options . url || this . urlRoot + options . path , qs : options . qs || { } , headers : options . headers || { } , } ; // Add `form`, `body`, or `json` as Request Payload (only one per request) // // If `json` is a Boolean, // Request will set` Content-Type` // and call `JSON.stringify()` on `body` if ( options . body ) { requestOptions . body = options . body ; requestOptions . json = _ . isBoolean ( options . json ) ? options . json : true ; } else if ( options . form ) { requestOptions . form = options . form ; requestOptions . headers [ 'Content-Type' ] = 'application/x-www-form-urlencoded; charset=utf-8' ; } else if ( _ . isBoolean ( options . json ) || _ . isObject ( options . json ) ) { requestOptions . json = options . json ; } // Basic HTTP Auth if ( options . auth ) { requestOptions . auth = options . auth ; } // Access Token var accessToken = options . access_token || this . get ( 'access_token' ) ; if ( accessToken ) { _ . defaults ( requestOptions . headers , { Authorization : [ 'Bearer' , accessToken ] . join ( ' ' ) } ) ; } // OAuth Token var oauthToken = options . oauth_token || this . get ( 'oauth_token' ) ; if ( oauthToken ) { _ . defaults ( requestOptions . headers , { Authorization : [ 'OAuth' , oauthToken ] . join ( ' ' ) } ) ; } // Authorization Token (No Scheme) var authorizationToken = options . authorization_token || this . get ( 'authorization_token' ) ; if ( authorizationToken ) { _ . defaults ( requestOptions . headers , { Authorization : authorizationToken } ) ; } return requestOptions ; }
Build and configure the request options

@param {Object} options
@param {String} options.url
@param {String} [options.path=]
@param {String} [options.method=GET]
@param {String} [options.qs={}]
@param {String} [options.headers={}]
@param {String} options.json
@param {String} options.form
@param {String} options.body
@param {String} options.access_token
@param {String} options.oauth_token
@param {String} options.authorization_token
@param {String} options.auth
@return {Object}
Build and configure the request options