Files
Undecked/Backend/dist/Integrations/buildin/getiyo/getiyo.js
2023-08-29 19:55:48 +02:00

182 lines
7.3 KiB
JavaScript

exports.__esModule = 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 this.serverProtocol + "://" + this.serverAddress + ":" + this.serverPort + "/" + this.channelName + "/api/v1/" + 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/" + sceneID + "/" + 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/" + 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/" + 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/" + 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/" + 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/" + 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/" + encodeURI(sectionName) + "/" + 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