<commit_before>'use strict';

module.exports = function ($http, $q, SessionInfo, $httpParamSerializer, kAppConfig, $sessionStorage) {

    var self = this;
    var isIE = (!!window.ActiveXObject && +(/msie\s(\d+)/i.exec(navigator.userAgent)[1])) || NaN;


    /**
     * format params as &key1=val1&key2=val2
     * @param params
     * @returns {String}
     */
    function serializeParams(params, parentKey) {
        var s = '';
        for (var key in params) {
            var value = params[key];

            if (s) {
                s += '&';
            }
            if (angular.isObject(value)) {
                s += serializeParams(value, key);
            } else {
                if (parentKey) {
                    s += parentKey + ':' + key + '=' + value;

                } else {
                    s += key + '=' + value;

                }
            }
        }
        return s;
    };


    function invokeAPIRequest(requestParams,queryParams) {
        // temporary bypass to ks
        SessionInfo.setKs($sessionStorage.ks);

        // Creating a deferred object
        var deferred = $q.defer();

        var parsedRequestParams;
        var method;

        if (isIE < 10) {
            method = 'jsonp';
            parsedRequestParams = $.extend(true, {}, requestParams, {
                ks: SessionInfo.ks,
                'callback': 'JSON_CALLBACK',
                'format': '9'
            });
        }
        else {
            method = "post";
            parsedRequestParams = $.extend(true, {}, requestParams, {
                ks: SessionInfo.ks,
                'format': '1'
            });
        }

        var url = kAppConfig.server.apiUri;
        if (queryParams)
        {
            url += '?' + $httpParamSerializer(queryParams);<commit_msg>using ka from kmc-hoster (or querystring as fallback plan) with kaltura api<commit_after>'use strict';

module.exports = function ($http, $q, kaKMCConfig, $httpParamSerializer, kAppConfig) {

    var self = this;
    var isIE = (!!window.ActiveXObject && +(/msie\s(\d+)/i.exec(navigator.userAgent)[1])) || NaN;


    /**
     * format params as &key1=val1&key2=val2
     * @param params
     * @returns {String}
     */
    function serializeParams(params, parentKey) {
        var s = '';
        for (var key in params) {
            var value = params[key];

            if (s) {
                s += '&';
            }
            if (angular.isObject(value)) {
                s += serializeParams(value, key);
            } else {
                if (parentKey) {
                    s += parentKey + ':' + key + '=' + value;

                } else {
                    s += key + '=' + value;

                }
            }
        }
        return s;
    };


    function invokeAPIRequest(requestParams,queryParams) {


        // Creating a deferred object
        var deferred = $q.defer();

        var parsedRequestParams;
        var method;

        if (isIE < 10) {
            method = 'jsonp';
            parsedRequestParams = $.extend(true, {}, requestParams, {
                ks: kaKMCConfig.ks,
                'callback': 'JSON_CALLBACK',
                'format': '9'
            });
        }
        else {
            method = "post";
            parsedRequestParams = $.extend(true, {}, requestParams, {
                ks: kaKMCConfig.ks,
                'format': '1'
            });
        }

        var url = kAppConfig.server.apiUri;
        if (queryParams)
        {
            url += '?' + $httpParamSerializer(queryParams);
{'fraction_non_alphanumeric': 0.13133576029123495, 'fraction_numerical': 0.00504060487258471, 'mean_word_length': 1.411883862255233, 'pattern_counts': {'":': 0, '<': 5, '<?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': '683056', 'n_tokens_mistral': 1047, 'n_tokens_neox': 982, 'n_words': 222}