<commit_before>'use strict';

var constants = require('../constants');
var Client    = require('../client');

module.exports = {

    oauthRequest : function(apiName, endpointName, accessToken, method, path, queryParams, bodyParams, headers)
    {
        var client, flux = this;

        if (! accessToken) {
            return this.dispatch(constants.REQUEST_FAILURE);
        }

        client = new Client(apiName);

        client.authRequest(accessToken, method, path, queryParams, bodyParams, headers)
            .then(
                function(response) {
                    flux.dispatch(constants.REQUEST_SUCCESS, {
                        endpointName : endpointName,
                        response     : response
                    });
                },
                function() {
                    flux.dispatch(constants.REQUEST_FAILURE, endpointName);
                }
            ).done();

        flux.dispatch(constants.REQUEST, {
            requestInfo  : client.getLastRequestInfo(),
            endpointName : endpointName
        });
    },

    request : function(apiName, endpointName, method, path, queryParams, bodyParams, headers, bodyType)
    {
        var client, flux = this;

        client = new Client(apiName);

        if (bodyType == 'json-param') {
            bodyParams = bodyParams[Object.keys(bodyParams)[0]];
        }

        client.request(method, path, queryParams, bodyParams, headers)
            .then(
                function(response) {
                    flux.dispatch(constants.REQUEST_SUCCESS, {
                        endpointName : endpointName,
                        response     : response
                    });
                },
                function() {
                    flux.dispatch(constants.REQUEST_FAILURE, endpointName);
                }
            ).done();

        flux.dispatch(constants.REQUEST, {
            requestInfo  : client.getLastRequestInfo(),
            endpointName : endpointName
        });
    },

    setRequestValues : function(endpointName, values)
    {
        this.dispatch(constants.SET_REQUEST_VALUES, {
            endpointName : endpointName,
            values       : values
        });
    },

    addToExcludedFields : function(endpointName, field)
    {
        this.dispatch(constants.REQUEST_ADD_TO_EXCLUDED_FIELDS, {
            endpointName : endpointName,
            field        : field
        });
    },

    removeFromExcludedFields : function(endpointName, field)
    {
        this.dispatch(constants.REQUEST_REMOVE_FROM_EXCLUDED_FIELDS, {
            endpointName : endpointName,
            field        : field
        });
    },

    addToNullFields : function(endpointName, field)
    {
        this.dispatch(constants.SET_NULL_VALUE, {
            endpointName : endpointName,
            field        : field
        });
    },

    removeFromNullFields : function(endpointName, field)
    {
        this.dispatch(constants.UNSET_NULL_VALUE, {
            endpointName : endpointName,
            field        : field
        });
    }
};
<commit_msg>jshint fix #60<commit_after>'use strict';

var constants = require('../constants');
var Client    = require('../client');

module.exports = {

    oauthRequest : function(apiName, endpointName, accessToken, method, path, queryParams, bodyParams, headers)
    {
        var client, flux = this;

        if (! accessToken) {
            return this.dispatch(constants.REQUEST_FAILURE);
        }

        client = new Client(apiName);

        client.authRequest(accessToken, method, path, queryParams, bodyParams, headers)
            .then(
                function(response) {
                    flux.dispatch(constants.REQUEST_SUCCESS, {
                        endpointName : endpointName,
                        response     : response
                    });
                },
                function() {
                    flux.dispatch(constants.REQUEST_FAILURE, endpointName);
                }
            ).done();

        flux.dispatch(constants.REQUEST, {
            requestInfo  : client.getLastRequestInfo(),
            endpointName : endpointName
        });
    },

    request : function(apiName, endpointName, method, path, queryParams, bodyParams, headers, bodyType)
    {
        var client, flux = this;

        client = new Client(apiName);

        if (bodyType === 'json-param') {
            bodyParams = bodyParams[Object.keys(bodyParams)[0]];
        }

        client.request(method, path, queryParams, bodyParams, headers)
            .then(
                function(response) {
                    flux.dispatch(constants.REQUEST_SUCCESS, {
                        endpointName : endpointName,
                        response     : response
                    });
                },
                function() {
                    flux.dispatch(constants.REQUEST_FAILURE, endpointName);
                }
            ).done();

        flux.dispatch(constants.REQUEST, {
            requestInfo  : client.getLastRequestInfo(),
            endpointName : endpointName
        });
    },

    setRequestValues : function(endpointName, values)
    {
        this.dispatch(constants.SET_REQUEST_VALUES, {
            endpointName : endpointName,
            values       : values
        });
    },

    addToExcludedFields : function(endpointName, field)
    {
        this.dispatch(constants.REQUEST_ADD_TO_EXCLUDED_FIELDS, {
            endpointName : endpointName,
            field        : field
        });
    },

    removeFromExcludedFields : function(endpointName, field)
    {
        this.dispatch(constants.REQUEST_REMOVE_FROM_EXCLUDED_FIELDS, {
            endpointName : endpointName,
            field        : field
        });
    },

    addToNullFields : function(endpointName, field)
    {
        this.dispatch(constants.SET_NULL_VALUE, {
            endpointName : endpointName,
            field        : field
        });
    },

    removeFromNullFields : function(endpointName, field)
    {
        this.dispatch(constants.UNSET_NULL_VALUE, {
            endpointName : endpointName,
            field        : field
        });
    }
};

{'fraction_non_alphanumeric': 0.09536082474226804, 'fraction_numerical': 0.0006443298969072165, 'mean_word_length': 1.6298178737822957, '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': '492965', 'n_tokens_mistral': 1551, 'n_tokens_neox': 1513, 'n_words': 268}