cordova.define("com.paidui.plugins.shangrun.ShangRun", function(require, exports, module) { 

    var ShangrunLoader = function (require, exports, module) {

        var exec = require("cordova/exec");

        /**
         * Constructor.
         *
         * @returns {Shangrun}
         */
        function Shangrun() {
        };

        Shangrun.prototype.checkEnv = function(successCallback, errorCallback) {
            
            successCallback = successCallback || function(){};
            errorCallback = errorCallback || function(){};

            if (typeof errorCallback != "function") {
                console.log("Sunmi.checkEnv failure: failure parameter not a function");
                return;
            }

            if (typeof successCallback != "function") {
                console.log("Sunmi.checkEnv failure: success callback parameter must be a function");
                return;
            }

            exec(successCallback, errorCallback, 'ShangRun', 'checkEnv', []);
        }

        /**
         * 打印测试
         * @param  {Function} successCallback 成功回调
         * @param  {Function} errorCallback   失败回调
         */
        Shangrun.prototype.printTest = function (successCallback, errorCallback) {

            successCallback = successCallback || function(){};
            errorCallback = errorCallback || function(){};

            if (typeof errorCallback != "function") {
                console.log("Sunmi.printTest failure: failure parameter not a function");
                return;
            }

            if (typeof successCallback != "function") {
                console.log("Sunmi.printTest failure: success callback parameter must be a function");
                return;
            }

            exec(successCallback, errorCallback, 'ShangRun', 'printTest', []);
        };

        /**
         * 打印小票、台单等
         * @param  {Object} config          小票、台单格式,格式为[[{},{}],[{},{}]],多套打印票据
         * @param  {Function} successCallback 成功后的回调
         * @param  {Function} errorCallback   失败后的回调
         */
        Shangrun.prototype.printTicket = function (config, successCallback, errorCallback) {
            if (config instanceof Array) {
                if (config.length > 0){
                    if (!(config[0] instanceof Array)) {
                        config = [config];
                    }
                }
            } else {
                config = [];
            }

            successCallback = successCallback || function(){};
            errorCallback = errorCallback || function(){};

            if (typeof errorCallback != "function") {
                console.log("Sunmi.printTicket failure: failure parameter not a function");
                return;
            }

            if (typeof successCallback != "function") {
                console.log("Sunmi.printTicket failure: success callback parameter must be a function");
                return;
            }

            exec(successCallback, errorCallback, 'ShangRun', 'printTicket', config);
        };


        /**
         * 盒子支付调用方法
         * @param  {Object} config          订单信息
         * @param  {Function} successCallback 成功后的回调
         * @param  {Function} errorCallback   失败后的回调
         */
        Shangrun.prototype.payOrder = function (config, successCallback, errorCallback) {
            if (config instanceof Array) {
                // do nothing
            } else {
                if (typeof(config) === 'object') {
                    config = [config];
                } else {
                    config = [];
                }
            }

            successCallback = successCallback || function(){};
            errorCallback = errorCallback || function(){};

            if (typeof errorCallback != "function") {
                console.log("Sunmi.payOrder failure: failure parameter not a function");
                return;
            }

            if (typeof successCallback != "function") {
                console.log("Sunmi.payOrder failure: success callback parameter must be a function");
                return;
            }

            exec(successCallback, errorCallback, 'Sunmi', 'payOrder', config);
        };

        /**
         * 退出程序时的清理
         * @param  {Function} successCallback 成功后的回调
         * @param  {Function} errorCallback   失败后的回调
         */
        Shangrun.prototype.clearOnExit = function (successCallback, errorCallback) {

            successCallback = successCallback || function(){};
            errorCallback = errorCallback || function(){};

            if (typeof errorCallback != "function") {
                console.log("Sunmi.clearOnExit failure: failure parameter not a function");
                return;
            }

            if (typeof successCallback != "function") {
                console.log("Sunmi.clearOnExit failure: success callback parameter must be a function");
                return;
            }

            exec(successCallback, errorCallback, 'ShangRun', 'clearOnExit', []);
        };
        

        var Shangrun = new Shangrun();
        module.exports = Shangrun;

    }

    ShangrunLoader(require, exports, module);

    cordova.define("cordova/plugin/shangrun", ShangrunLoader);



});
