<commit_before>"use strict";

var _ = require('lodash'),
    common = require('ng-common'),
    Methods = common.net.Methods,
    GsonParser = common.net.GsonParser;

var RestAdapter = function (httpClient) {
    this._httpClient = httpClient;
    this._endpoint = "";
};

RestAdapter.prototype.create = function (RestInterface) {
    return _.mapValues(RestInterface.prototype, function (value) {
        return _.bind(function (ar) {
            var parser = null,
                data = null,
                args = Array.prototype.slice.apply(arguments);
            //Add parser
            if (value.type)
                parser = new GsonParser([value.type]);
            //Add request body
            if (value.method === Methods.POST || value.method === Methods.PUT)
                data = _.last(args);
            //Replace url params
            _.forEach(args, function (arg) {
                value.url = value.url.replace(/\$\{\}/, arg);
            });
            return this._getNetworPromise(value.method, this._endpoint + value.url, data, parser);
        }, this);
    }, this);
};

RestAdapter.prototype._getNetworPromise = function (method, url, data, parser) {
    switch (method) {
        case Methods.GET:
            return this._httpClient.get(url, parser);
        case Methods.POST:
            return this._httpClient.post(url, data, parser);
        case Methods.PUT:<commit_msg>Remove typo<commit_after>"use strict";

var _ = require('lodash'),
    common = require('ng-common'),
    Methods = common.net.Methods,
    GsonParser = common.net.GsonParser;

var RestAdapter = function (httpClient) {
    this._httpClient = httpClient;
    this._endpoint = "";
};

RestAdapter.prototype.create = function (RestInterface) {
    return _.mapValues(RestInterface.prototype, function (value) {
        return _.bind(function () {
            var parser = null,
                data = null,
                args = Array.prototype.slice.apply(arguments);
            //Add parser
            if (value.type)
                parser = new GsonParser([value.type]);
            //Add request body
            if (value.method === Methods.POST || value.method === Methods.PUT)
                data = _.last(args);
            //Replace url params
            _.forEach(args, function (arg) {
                value.url = value.url.replace(/\$\{\}/, arg);
            });
            return this._getNetworPromise(value.method, this._endpoint + value.url, data, parser);
        }, this);
    }, this);
};

RestAdapter.prototype._getNetworPromise = function (method, url, data, parser) {
    switch (method) {
        case Methods.GET:
            return this._httpClient.get(url, parser);
        case Methods.POST:
            return this._httpClient.post(url, data, parser);
        case Methods.PUT:
{'fraction_non_alphanumeric': 0.12898653437278526, 'fraction_numerical': 0.0, 'mean_word_length': 2.0684782608695653, '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': '6924208', 'n_tokens_mistral': 777, 'n_tokens_neox': 752, 'n_words': 177}