@akkadu/rsi-api-base
Advanced tools
Comparing version 0.2.8 to 0.2.9
export default class Base { | ||
emitter: any; | ||
RSI_GATEWAY_API: string; | ||
constructor(); | ||
gatewayRequest(apiKey: string, roomName: string): Promise<{ | ||
/** | ||
* @description It authenticates the apiKey by checking on our dynamoDb rsi-api-table | ||
* that the apiKey exist | ||
* and that this apiKey is associated to that roomName | ||
* @param {string} apiKey | ||
* @param {string} roomName | ||
* @returns {Promise} {stream:object, languageState:string, eventLanguages:array} | ||
*/ | ||
gatewayAuthenticate(apiKey: string, roomName: string): Promise<{ | ||
stream: any; | ||
@@ -6,0 +15,0 @@ languageState: any; |
@@ -40,13 +40,20 @@ "use strict"; | ||
var events_1 = require("events"); | ||
/* const axios = require('axios') */ | ||
var Base = /** @class */ (function () { | ||
function Base() { | ||
this.emitter = new events_1.EventEmitter(); | ||
this.RSI_GATEWAY_API = "https://54i2k0z0vf.execute-api.cn-north-1.amazonaws.com.cn/prod"; | ||
} | ||
Base.prototype.gatewayRequest = function (apiKey, roomName) { | ||
var _a, _b, _c; | ||
/** | ||
* @description It authenticates the apiKey by checking on our dynamoDb rsi-api-table | ||
* that the apiKey exist | ||
* and that this apiKey is associated to that roomName | ||
* @param {string} apiKey | ||
* @param {string} roomName | ||
* @returns {Promise} {stream:object, languageState:string, eventLanguages:array} | ||
*/ | ||
Base.prototype.gatewayAuthenticate = function (apiKey, roomName) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var eventRequest, eventId, streamRequest, eventLanguagesRequest, eventLanguageState, stream, eventLanguages, languageState; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
var rawResponse, content, body, _a, stream, languageState, eventLanguages; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
@@ -59,25 +66,20 @@ if (!apiKey) { | ||
} | ||
return [4 /*yield*/, fetch("https://devapi.akkadu.com/v2/events/?roomName=" + roomName)]; | ||
case 1: return [4 /*yield*/, (_d.sent()).json()]; | ||
return [4 /*yield*/, fetch(this.RSI_GATEWAY_API + "/authenticate", { | ||
method: 'POST', | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ apiKey: apiKey, roomName: roomName }) | ||
})]; | ||
case 1: | ||
rawResponse = _b.sent(); | ||
return [4 /*yield*/, rawResponse.json()]; | ||
case 2: | ||
eventRequest = _d.sent(); | ||
eventId = (_c = (_b = (_a = eventRequest === null || eventRequest === void 0 ? void 0 : eventRequest.data) === null || _a === void 0 ? void 0 : _a.events) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.id; | ||
if (!eventId) { | ||
throw Error('no eventId for this event'); | ||
content = _b.sent(); | ||
body = content.body; | ||
if (body.error) { | ||
throw Error("interpretation-player: An error occured: " + body.error); | ||
} | ||
return [4 /*yield*/, fetch("https://devapi.akkadu.com/v2/events/" + eventId + "/streams")]; | ||
case 3: return [4 /*yield*/, (_d.sent()).json()]; | ||
case 4: | ||
streamRequest = _d.sent(); | ||
return [4 /*yield*/, (fetch("https://devapi.akkadu.com/v2/events/" + eventId + "/languages"))]; | ||
case 5: return [4 /*yield*/, (_d.sent()).json()]; | ||
case 6: | ||
eventLanguagesRequest = _d.sent(); | ||
return [4 /*yield*/, (fetch("https://devapi.akkadu.com/v2/language-state?roomname=" + roomName))]; | ||
case 7: return [4 /*yield*/, (_d.sent()).json()]; | ||
case 8: | ||
eventLanguageState = _d.sent(); | ||
stream = streamRequest === null || streamRequest === void 0 ? void 0 : streamRequest.data; | ||
eventLanguages = eventLanguagesRequest === null || eventLanguagesRequest === void 0 ? void 0 : eventLanguagesRequest.data.languages; | ||
languageState = eventLanguageState === null || eventLanguageState === void 0 ? void 0 : eventLanguageState.data.languageState; | ||
_a = body.data, stream = _a.stream, languageState = _a.languageState, eventLanguages = _a.eventLanguages; | ||
return [2 /*return*/, { stream: stream, languageState: languageState, eventLanguages: eventLanguages }]; | ||
@@ -84,0 +86,0 @@ } |
{ | ||
"name": "@akkadu/rsi-api-base", | ||
"version": "0.2.8", | ||
"version": "0.2.9", | ||
"description": ",", | ||
@@ -30,3 +30,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "85c18f60dc63b96012fb433e678b95aadf6717a1" | ||
"gitHead": "53bf02ec0079239b793cafe9273fcc970e570ea8" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
112
1
6789