<commit_before>'use strict';

var HttpGateway = require('synapse-common/http/gateway');
var Q           = require('q');
var http        = require('http');
var https       = require('https');
var config      = require('./config');
var _           = require('underscore');

module.exports = HttpGateway.extend({

    constructor : function(namespace)
    {
        this.config = config.apis[namespace].api;
        this.oauthConfig = config.apis[namespace].oauth2;
    },

    /**
     * Make a request without authentication
     *
     * @param  {String} method      HTTP method
     * @param  {String} path        Endpoint path
     * @param  {Object} queryParams
     * @param  {Object} bodyParams
     * @param  {Object} headers
     * @return promise
     */
    request : function(method, path, queryParams, bodyParams, headers)
    {
        this.accessToken = false;

        return this.apiRequest(
            method,
            path,
            queryParams,
            bodyParams,
            headers
        );
    },

    /**
     * Make a request with authentication
     *
     * @param  {String} method      HTTP method
     * @param  {String} path        Endpoint path
     * @param  {Object} queryParams [description]
     * @param  {Object} bodyParams  [description]
     * @param  {Object} headers     [description]
     * @return promise
     */
    authRequest : function(accessToken, method, path, queryParams, bodyParams, headers)
    {
        this.accessToken = accessToken;

        return this.apiRequest(
            method,
            path,
            queryParams,
            bodyParams,
            headers
        );
    },

    /**
     * Set the info returned by getLastRequestInfo
     *
     * @param  {String} method      HTTP method
     * @param  {String} path        Endpoint path
     * @param  {Object} queryParams [description]
     * @param  {Object} bodyParams  [description]
     * @param  {Object} headers     [description]
     */
    setLastRequestInfo : function(method, path, queryParams, bodyParams, headers)
    {
        var uri, config, data;

        config = this.getConfig();

        uri = (config.secure ? 'https' : 'http') + '://' + config.hostname + path;
<commit_msg>Refs #101 | Display GET querystring params in Request URI box<commit_after>'use strict';

var HttpGateway = require('synapse-common/http/gateway');
var Q           = require('q');
var http        = require('http');
var https       = require('https');
var config      = require('./config');
var _           = require('underscore');

module.exports = HttpGateway.extend({

    constructor : function(namespace)
    {
        this.config = config.apis[namespace].api;
        this.oauthConfig = config.apis[namespace].oauth2;
    },

    /**
     * Make a request without authentication
     *
     * @param  {String} method      HTTP method
     * @param  {String} path        Endpoint path
     * @param  {Object} queryParams
     * @param  {Object} bodyParams
     * @param  {Object} headers
     * @return promise
     */
    request : function(method, path, queryParams, bodyParams, headers)
    {
        this.accessToken = false;

        return this.apiRequest(
            method,
            path,
            queryParams,
            bodyParams,
            headers
        );
    },

    /**
     * Make a request with authentication
     *
     * @param  {String} method      HTTP method
     * @param  {String} path        Endpoint path
     * @param  {Object} queryParams [description]
     * @param  {Object} bodyParams  [description]
     * @param  {Object} headers     [description]
     * @return promise
     */
    authRequest : function(accessToken, method, path, queryParams, bodyParams, headers)
    {
        this.accessToken = accessToken;

        return this.apiRequest(
            method,
            path,
            queryParams,
            bodyParams,
            headers
        );
    },

    /**
     * Set the info returned by getLastRequestInfo
     *
     * @param  {String} method      HTTP method
     * @param  {String} path        Endpoint path
     * @param  {Object} queryParams [description]
     * @param  {Object} bodyParams  [description]
     * @param  {Object} headers     [description]
     */
    setLastRequestInfo : function(method, path, queryParams, bodyParams, headers)
    {
        var uri, config, data;

        config = this.getConfig();

        if (queryParams && ! _(queryParams).isEmpty()) {
            path = path + '?' + this._toQuery(queryParams);
        }

        uri = (config.secure ? 'https' : 'http') + '://' + config.hostname + path;

{'fraction_non_alphanumeric': 0.11192423590185105, 'fraction_numerical': 0.001076194575979337, 'mean_word_length': 1.978846153846154, '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': '770721', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1254, 'n_words': 333}