Object.defineProperty(exports, "__esModule", { value: true });
exports.Getiyo = void 0;
var axios_1 = require("axios");
var Getiyo = /** @class */ (function () {
    function Getiyo(settings) {
        this.serverProtocol = settings.serverProtocol != undefined ? settings.serverProtocol : 'http';
        this.serverAddress = settings.serverAddress;
        this.serverPort = settings.serverPort;
        this.channelName = settings.channelName;
        this.channelApiKey = settings.channelApiKey;
    }
    Getiyo.prototype._getBaseURI = function () {
        return "".concat(this.serverProtocol, "://").concat(this.serverAddress, ":").concat(this.serverPort, "/").concat(this.channelName, "/api/v1/").concat(this
            .channelApiKey, "/");
    };
    Getiyo.prototype.checkConnection = function (callback) {
        axios_1.default.get(this._getBaseURI()).then(function () { return callback(true); }).catch(function () { return callback(false); });
    };
    Getiyo.prototype.getScenes = function () {
        var _this = this;
        return new Promise(function (resolve, reject) {
            axios_1.default
                .get(_this._getBaseURI() + 'scenes')
                .then(function (response) {
                if (response.data.succeed == true) {
                    resolve(response.data.response);
                }
                else
                    reject(new Error('Unable to connection to Getiyo instance'));
            })
                .catch(reject);
        });
    };
    Getiyo.prototype.getDisplays = function () {
        var _this = this;
        return new Promise(function (resolve, reject) {
            axios_1.default
                .get(_this._getBaseURI() + 'displays')
                .then(function (response) {
                if (response.data.succeed == true) {
                    resolve(response.data.response);
                }
                else
                    reject(new Error('Unable to connection to Getiyo instance'));
            })
                .catch(reject);
        });
    };
    Getiyo.prototype.getModules = function () {
        var _this = this;
        return new Promise(function (resolve, reject) {
            axios_1.default
                .get(_this._getBaseURI() + 'modules')
                .then(function (response) {
                if (response.data.succeed == true) {
                    resolve(response.data.response);
                }
                else
                    reject(new Error('Unable to connection to Getiyo instance'));
            })
                .catch(reject);
        });
    };
    Getiyo.prototype.getTimelineSections = function () {
        var _this = this;
        return new Promise(function (resolve, reject) {
            axios_1.default
                .get(_this._getBaseURI() + 'timeline/sections')
                .then(function (response) {
                if (response.data.succeed == true) {
                    resolve(response.data.response);
                }
                else
                    reject(new Error('Unable to connection to Getiyo instance'));
            })
                .catch(reject);
        });
    };
    Getiyo.prototype.publishScene = function (sceneID, displayID) {
        var _this = this;
        return new Promise(function (resolve, reject) {
            axios_1.default
                .get(_this._getBaseURI() + "scenes/publish/".concat(sceneID, "/").concat(displayID))
                .then(function (response) {
                if (response.data.succeed == true) {
                    resolve();
                }
                else
                    reject(new Error('Unable to connection to Getiyo instance'));
            })
                .catch(reject);
        });
    };
    Getiyo.prototype.startTimeline = function (createNewRunner) {
        var _this = this;
        if (createNewRunner === void 0) { createNewRunner = false; }
        return new Promise(function (resolve, reject) {
            axios_1.default
                .get(_this._getBaseURI() + "timeline/start/".concat(createNewRunner))
                .then(function (response) {
                if (response.data.succeed == true) {
                    resolve();
                }
                else
                    reject(new Error('Unable to connection to Getiyo instance'));
            })
                .catch(reject);
        });
    };
    Getiyo.prototype.stopTimeline = function (runnerID) {
        var _this = this;
        if (runnerID === void 0) { runnerID = 'main'; }
        return new Promise(function (resolve, reject) {
            axios_1.default
                .get(_this._getBaseURI() + "timeline/stop/".concat(runnerID))
                .then(function (response) {
                if (response.data.succeed == true) {
                    resolve();
                }
                else
                    reject(new Error('Unable to connection to Getiyo instance'));
            })
                .catch(reject);
        });
    };
    Getiyo.prototype.pauseTimeline = function (runnerID) {
        var _this = this;
        if (runnerID === void 0) { runnerID = 'main'; }
        return new Promise(function (resolve, reject) {
            axios_1.default
                .get(_this._getBaseURI() + "timeline/pause/".concat(runnerID))
                .then(function (response) {
                if (response.data.succeed == true) {
                    resolve();
                }
                else
                    reject(new Error('Unable to connection to Getiyo instance'));
            })
                .catch(reject);
        });
    };
    Getiyo.prototype.skipTimelineBlock = function (runnerID) {
        var _this = this;
        if (runnerID === void 0) { runnerID = 'main'; }
        return new Promise(function (resolve, reject) {
            axios_1.default
                .get(_this._getBaseURI() + "timeline/skip/".concat(runnerID))
                .then(function (response) {
                if (response.data.succeed == true) {
                    resolve();
                }
                else
                    reject(new Error('Unable to connection to Getiyo instance'));
            })
                .catch(reject);
        });
    };
    Getiyo.prototype.continueTimelineHold = function (runnerID) {
        var _this = this;
        if (runnerID === void 0) { runnerID = 'main'; }
        return new Promise(function (resolve, reject) {
            axios_1.default
                .get(_this._getBaseURI() + "timeline/hold/".concat(runnerID))
                .then(function (response) {
                if (response.data.succeed == true) {
                    resolve();
                }
                else
                    reject(new Error('Unable to connection to Getiyo instance'));
            })
                .catch(reject);
        });
    };
    Getiyo.prototype.jumpToTimelineSections = function (sectionName, runnerID) {
        var _this = this;
        if (runnerID === void 0) { runnerID = 'main'; }
        return new Promise(function (resolve, reject) {
            axios_1.default
                .get(_this._getBaseURI() + "timeline/sections/jump/".concat(encodeURI(sectionName), "/").concat(runnerID))
                .then(function (response) {
                if (response.data.succeed == true) {
                    resolve();
                }
                else
                    reject(new Error('Unable to connection to Getiyo instance'));
            })
                .catch(reject);
        });
    };
    return Getiyo;
}());
exports.Getiyo = Getiyo;
//# sourceMappingURL=getiyo.js.map