<commit_before>var version = require( '../package.json').version;
var request = require( 'request');
var _       = require( 'lodash' );

module.exports   = fuelRest;


function fuelRest( auth, uri, options, callback ) {

	var defaults = {
		method: 'GET',
		headers: {
			'User-Agent' : 'node-fuel/' + auth.version
		},
		json : true
	};

	options = _.merge( {}, defaults, options );

	options.uri    = uri;
	options.method = options.method;
	options.json   = options.json;

	if( options.body ) {
		// why does this need to be here? if there's an option.body it should not need to be reassigned
		options.body = options.body;
	}

	if( !auth.accessToken || !auth._checkExpired() ) {

		// make the request after getting new token
		auth.getAccessToken( function( err, res, body ) {

			if( err ) {
				callback( err );
				return;
			}

			options.headers.Authorization = 'Bearer ' + auth.accessToken;

			_makeRequest( options, callback );
		});
	}
	else {
		options.headers.Authorization = 'Bearer ' + auth.accessToken;

		_makeRequest( options, callback );
	}
}

function _makeRequest(options, callback){
	request(options, function (error,response,body){
		if (error) {
			callback(error);
		} else {
			callback(error,response,body);
		}
	})
}

fuelRest.version = version;<commit_msg>modified minor semantics<commit_after>var version = require( '../package.json').version;
var request = require( 'request');
var _       = require( 'lodash' );

module.exports   = FuelNodeRest;

function FuelNodeRest( auth, uri, options, callback ) {

	var defaults = {
		method: 'GET',
		headers: {
			'User-Agent' : 'node-fuel/' + auth.version
		},
		json : true
	};

	options = _.merge( {}, defaults, options );

	options.uri    = uri;
	options.method = options.method;
	options.json   = options.json;

	if( options.body ) {
		// why does this need to be here? if there's an option.body it should not need to be reassigned
		options.body = options.body;
	}

	if( !auth.accessToken || !auth._checkExpired() ) {

		// make the request after getting new token
		auth.getAccessToken( function( err, res, body ) {

			if( err ) {
				callback( err );
				return;
			}

			options.headers.Authorization = 'Bearer ' + auth.accessToken;

			_makeRequest( options, callback );
		});
	}
	else {
		options.headers.Authorization = 'Bearer ' + auth.accessToken;

		_makeRequest( options, callback );
	}
}

function _makeRequest(options, callback){
	request(options, function (error,response,body){
		if (error) {
			callback(error);
		} else {
			callback(error,response,body);
		}
	})
}

FuelNodeRest.version = version;
{'fraction_non_alphanumeric': 0.14021571648690292, 'fraction_numerical': 0.0, 'mean_word_length': 3.372053872053872, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1318496', 'n_tokens_mistral': 929, 'n_tokens_neox': 827, 'n_words': 215}