UNPKG

@bradgarropy/captivate-sdk

Version:
199 lines • 9.08 kB
"use strict"; exports.__esModule = true; var tslib_1 = require("tslib"); var authentication_1 = require("./authentication"); var episodes_1 = require("./episodes"); var media_1 = require("./media"); var shows_1 = require("./shows"); var users_1 = require("./users"); var Captivate = /** @class */ (function () { function Captivate(userId, apiKey) { var _this = this; this.authentication = { authenticateUser: function () { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () { var authenticatedUser; return (0, tslib_1.__generator)(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, (0, authentication_1.authenticateUser)(this.userId, this.apiKey)]; case 1: authenticatedUser = _a.sent(); this.token = authenticatedUser.token; return [2 /*return*/, authenticatedUser]; } }); }); } }; this.users = { getUser: function (userId) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () { var user; return (0, tslib_1.__generator)(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.authentication.authenticateUser()]; case 1: _a.sent(); return [4 /*yield*/, (0, users_1.getUser)(this.token, userId)]; case 2: user = _a.sent(); return [2 /*return*/, user]; } }); }); }, getUsersShows: function (userId) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () { var shows; return (0, tslib_1.__generator)(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.authentication.authenticateUser()]; case 1: _a.sent(); return [4 /*yield*/, (0, users_1.getUsersShows)(this.token, userId)]; case 2: shows = _a.sent(); return [2 /*return*/, shows]; } }); }); }, getUsersManagedShows: function (userId) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () { var shows; return (0, tslib_1.__generator)(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.authentication.authenticateUser()]; case 1: _a.sent(); return [4 /*yield*/, (0, users_1.getUsersManagedShows)(this.token, userId)]; case 2: shows = _a.sent(); return [2 /*return*/, shows]; } }); }); } }; this.shows = { getShow: function (showId) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () { var show; return (0, tslib_1.__generator)(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.authentication.authenticateUser()]; case 1: _a.sent(); return [4 /*yield*/, (0, shows_1.getShow)(this.token, showId)]; case 2: show = _a.sent(); return [2 /*return*/, show]; } }); }); }, updateShow: function () { // TODO }, updateShowArtwork: function () { // TODO }, getShowEpisodes: function (showId) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () { var episodes; return (0, tslib_1.__generator)(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.authentication.authenticateUser()]; case 1: _a.sent(); return [4 /*yield*/, (0, shows_1.getShowEpisodes)(this.token, showId)]; case 2: episodes = _a.sent(); return [2 /*return*/, episodes]; } }); }); }, getShowScheduledEpisodes: function (showId) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () { var scheduledEpisodes; return (0, tslib_1.__generator)(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.authentication.authenticateUser()]; case 1: _a.sent(); return [4 /*yield*/, (0, shows_1.getShowScheduledEpisodes)(this.token, showId)]; case 2: scheduledEpisodes = _a.sent(); return [2 /*return*/, scheduledEpisodes]; } }); }); }, getShowFeedUrl: function (showId) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () { var feed; return (0, tslib_1.__generator)(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.authentication.authenticateUser()]; case 1: _a.sent(); return [4 /*yield*/, (0, shows_1.getShowFeedUrl)(this.token, showId)]; case 2: feed = _a.sent(); return [2 /*return*/, feed]; } }); }); } }; this.media = { getMedia: function (mediaId) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () { var media; return (0, tslib_1.__generator)(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.authentication.authenticateUser()]; case 1: _a.sent(); return [4 /*yield*/, (0, media_1.getMedia)(this.token, mediaId)]; case 2: media = _a.sent(); return [2 /*return*/, media]; } }); }); }, uploadMedia: function () { // TODO }, getShowMedia: function (showId) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () { var showMedia; return (0, tslib_1.__generator)(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.authentication.authenticateUser()]; case 1: _a.sent(); return [4 /*yield*/, (0, media_1.getShowMedia)(this.token, showId)]; case 2: showMedia = _a.sent(); return [2 /*return*/, showMedia]; } }); }); }, searchShowMedia: function () { // TODO } }; this.episodes = { getEpisode: function (episodeId) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () { var episode; return (0, tslib_1.__generator)(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.authentication.authenticateUser()]; case 1: _a.sent(); return [4 /*yield*/, (0, episodes_1.getEpisode)(this.token, episodeId)]; case 2: episode = _a.sent(); return [2 /*return*/, episode]; } }); }); }, createEpisode: function () { // TODO }, updateEpisode: function () { // TODO } }; this.userId = userId; this.apiKey = apiKey; this.token = null; } return Captivate; }()); exports["default"] = Captivate; //# sourceMappingURL=captivate.js.map