<commit_before>'use strict';

/*
 * Module for juggling call state.
 */

angular.module('call', [])
.factory('callFactory', function (apiFactory) {
    var callStates = {
        error: 'error',
        not_answered: 'not_answered',
        succeeded: 'succeeded'
    };

    var currentCallID = null;

    var initiateCall = function (recipient) {
        return new Promise(function (resolve, reject) {
            apiFactory.call.initiate(recipient)
                .then(function (newCall) {
                    currentCallID = newCall.CallId;
                    resolve(newCall);
                })
                .catch(function (callErr) {
                    reject(callErr);
                });
        });
    };

    var endCall = function (finalStatus) {
        return new Promise(function (resolve, reject) {
            if (!currentCallID) {
                return reject(new Error('Current call ID is null!'));
            }

            apiFactory.call.end(finalStatus, currentCallID)
                .then(function (endedCall) {
                    resolve(endedCall);
                })
                .catch(function (error) {
                    reject(error);
                })
                .finally(function () {
                    currentCallID = null;
                });
        });
    };

    return {
        initiateCall: initiateCall,
        callStates: callStates,
        callError: function () {
            return endCall(callStates.error);
        },
        callSucceeded: function () {
            return endCall(callStates.succeeded);
        },
        callNotAnswered: function () {
            return endCall(callStates.not_answered);
        }
    };
});

<commit_msg>Fix call id parameter name<commit_after>'use strict';

/*
 * Module for juggling call state.
 */

angular.module('call', [])
.factory('callFactory', function (apiFactory) {
    var callStates = {
        error: 'error',
        not_answered: 'not_answered',
        succeeded: 'succeeded'
    };

    var currentCallID = null;

    var initiateCall = function (recipient) {
        return new Promise(function (resolve, reject) {
            apiFactory.call.initiate(recipient)
                .then(function (newCall) {
                    console.log(newCall);
                    currentCallID = newCall.id;
                    resolve(newCall);
                })
                .catch(function (callErr) {
                    reject(callErr);
                });
        });
    };

    var endCall = function (finalStatus) {
        return new Promise(function (resolve, reject) {
            if (!currentCallID) {
                return reject(new Error('Current call ID is null!'));
            }

            apiFactory.call.end(finalStatus, currentCallID)
                .then(function (endedCall) {
                    resolve(endedCall);
                })
                .catch(function (error) {
                    reject(error);
                })
                .finally(function () {
                    currentCallID = null;
                });
        });
    };

    return {
        initiateCall: initiateCall,
        callStates: callStates,
        callError: function () {
            return endCall(callStates.error);
        },
        callSucceeded: function () {
            return endCall(callStates.succeeded);
        },
        callNotAnswered: function () {
            return endCall(callStates.not_answered);
        }
    };
});


{'fraction_non_alphanumeric': 0.10885133199656259, 'fraction_numerical': 0.0, 'mean_word_length': 1.4608879492600422, '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': '336945', 'n_tokens_mistral': 942, 'n_tokens_neox': 867, 'n_words': 177}