<commit_before>var eppGenerator = require('./epp.js');
var eppConnection = require('./connection.js');
var parser = require('xml2json');

module.exports = function(registry, config) {
    var epp = eppGenerator(registry, config);
    var connection = eppConnection(config);
    return {
        "connection": connection,
        "state": "offline",
        "idle": function() {
            var self = this;
            this.state = 'idle';
            this.interval = setInterval(function() {
                self.command('hello', null, function() {
                    return {
                        "status": "OK"
                    };
                });
            },
            60000);
        },

        "resultOk": function(result) {
            if (result.status === 'OK') {
                return true;
            }
            return false;
        },

        // actions
        "login": function(data, callback) {
            var self = this;
            var xml = epp.login(data, 'test-1234');
            //console.log(xml);
            // send login
            this.connection.send(xml, callback);
            return xml;
        },

        "logout": function(callback) {
            var self = this;
            var xml = epp.logout('test-1234');
            console.log(xml);
            // send login
            this.connection.send(xml, callback);
            return xml;
        },

        "hello": function() {
            var self = this;
            var xml = epp.hello();
            console.log(xml);
            this.connection.send(xml, function(returnedXML) {
                var response = parser.toJson(returnedXML);
                console.log("Hello response: ", response);
                self.idle();
            });
        },

        "createContact": function(data, callback) {
            var self = this;
            var xml = epp.createContact(data, 'test-check-1234');
            this.connection.send(xml, callback);
        },
        "checkContact": function(data, callback) {
            var self = this;
            var xml = epp.checkContact(data, 'test-check-1234');
            this.connection.send(xml, callback);
        },
        "infoContact": function(data, callback) {
            var self = this;
            var xml = epp.infoContact(data, 'test-info-1234');
            this.connection.send(xml, callback);
        },
        "checkDomain": function(data, callback) {
            var self = this;
            var xml = epp.checkDomain(data, 'test-check-1234');
            this.connection.send(xml, callback);
        },
        "createDomain": function(data, callback) {
            var self = this;
            var xml = epp.createDomain(data, 'test-create-1234');
            this.connection.send(xml, callback);
        },
        "infoDomain": function(data, callback) {
            var self = this;
            var xml = epp.infoDomain(data, 'test-info-1234');
            this.connection.send(xml, callback);
        },

        "domain_command": function(command, data, callback) {
            console.log("Executing a " + command + " with: ", data);
            var result = callback();
            this.idle();
            return result;
        },
        "contact_command": function(command, data, callback) {
            console.log("Executing a " + command + " with: ", data);
            var result = callback();
            this.idle();
            return result;
        },
        "processResponse": function (eppJson) {
            var eppData = eppJson.epp;
            console.log("Epp data: ", eppData);
            if (eppData) {
                var eppResponse = eppData.response;
                var returnData = {
                    "result": eppResponse.result,
                    "data": eppResponse.resData,
                    "transactionId": eppResponse.trID
                };
                return returnData;<commit_msg>dump out the whole structure<commit_after>var eppGenerator = require('./epp.js');
var eppConnection = require('./connection.js');
var parser = require('xml2json');

module.exports = function(registry, config) {
    var epp = eppGenerator(registry, config);
    var connection = eppConnection(config);
    return {
        "connection": connection,
        "state": "offline",
        "idle": function() {
            var self = this;
            this.state = 'idle';
            this.interval = setInterval(function() {
                self.command('hello', null, function() {
                    return {
                        "status": "OK"
                    };
                });
            },
            60000);
        },

        "resultOk": function(result) {
            if (result.status === 'OK') {
                return true;
            }
            return false;
        },

        // actions
        "login": function(data, callback) {
            var self = this;
            var xml = epp.login(data, 'test-1234');
            //console.log(xml);
            // send login
            this.connection.send(xml, callback);
            return xml;
        },

        "logout": function(callback) {
            var self = this;
            var xml = epp.logout('test-1234');
            console.log(xml);
            // send login
            this.connection.send(xml, callback);
            return xml;
        },

        "hello": function() {
            var self = this;
            var xml = epp.hello();
            console.log(xml);
            this.connection.send(xml, function(returnedXML) {
                var response = parser.toJson(returnedXML);
                console.log("Hello response: ", response);
                self.idle();
            });
        },

        "createContact": function(data, callback) {
            var self = this;
            var xml = epp.createContact(data, 'test-check-1234');
            this.connection.send(xml, callback);
        },
        "checkContact": function(data, callback) {
            var self = this;
            var xml = epp.checkContact(data, 'test-check-1234');
            this.connection.send(xml, callback);
        },
        "infoContact": function(data, callback) {
            var self = this;
            var xml = epp.infoContact(data, 'test-info-1234');
            this.connection.send(xml, callback);
        },
        "checkDomain": function(data, callback) {
            var self = this;
            var xml = epp.checkDomain(data, 'test-check-1234');
            this.connection.send(xml, callback);
        },
        "createDomain": function(data, callback) {
            var self = this;
            var xml = epp.createDomain(data, 'test-create-1234');
            this.connection.send(xml, callback);
        },
        "infoDomain": function(data, callback) {
            var self = this;
            var xml = epp.infoDomain(data, 'test-info-1234');
            this.connection.send(xml, callback);
        },

        "domain_command": function(command, data, callback) {
            console.log("Executing a " + command + " with: ", data);
            var result = callback();
            this.idle();
            return result;
        },
        "contact_command": function(command, data, callback) {
            console.log("Executing a " + command + " with: ", data);
            var result = callback();
            this.idle();
            return result;
        },
        "processResponse": function (eppJson) {
            console.log("Epp data: ", eppJson);
            var eppData = eppJson.epp;
            if (eppData) {
                var eppResponse = eppData.response;
                var returnData = {
                    "result": eppResponse.result,
                    "data": eppResponse.resData,
                    "transactionId": eppResponse.trID
                };
                return returnData;
{'fraction_non_alphanumeric': 0.12654046499809427, 'fraction_numerical': 0.009655698132384703, 'mean_word_length': 1.4824976348155157, 'pattern_counts': {'":': 40, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 48}, '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': '768717', 'n_tokens_mistral': 2107, 'n_tokens_neox': 2017, 'n_words': 455}