UNPKG

recall_sdk

Version:

Node js sdk for the recall ai api

135 lines (134 loc) 6.05 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Bot = void 0; const recall_axios_1 = require("../recall-axios"); const try_catch_wrapper_1 = require("../try-catch-wrapper"); class Bot { constructor({ apiKey, botUrl }) { this.botUrl = botUrl; this.client = recall_axios_1.RecallAxios.getInstance({ apiKey }); } static getInstance({ apiKey, botUrl, }) { if (!Bot.instance) { Bot.instance = new Bot({ apiKey, botUrl }); } return Bot.instance; } list(params) { return __awaiter(this, void 0, void 0, function* () { const url = this.botUrl; return (0, try_catch_wrapper_1.recallRequestTryCatchWrapper)(() => this.client.get(url, { params })); }); } create(params) { return __awaiter(this, void 0, void 0, function* () { const url = this.botUrl; return (0, try_catch_wrapper_1.recallRequestTryCatchWrapper)(() => this.client.post(url, Object.assign({}, params), { headers: { "Content-Type": "application/json", }, })); }); } listChatMessages(params) { return __awaiter(this, void 0, void 0, function* () { const url = `${this.botUrl}/${params.id}/chat-messages/`; const { cursor, ordering } = params; return (0, try_catch_wrapper_1.recallRequestTryCatchWrapper)(() => this.client.get(url, { params: { cursor, ordering } })); }); } retrieve(params) { return __awaiter(this, void 0, void 0, function* () { const url = `${this.botUrl}/${params.id}`; return (0, try_catch_wrapper_1.recallRequestTryCatchWrapper)(() => this.client.get(url)); }); } updateScheduledBot(params) { return __awaiter(this, void 0, void 0, function* () { const { id } = params, bodyParams = __rest(params, ["id"]); const url = `${this.botUrl}/${id}/`; return (0, try_catch_wrapper_1.recallRequestTryCatchWrapper)(() => this.client.patch(url, Object.assign({}, bodyParams), { headers: { "Content-Type": "application/json", }, })); }); } deleteScheduledBot(params) { return __awaiter(this, void 0, void 0, function* () { const url = `${this.botUrl}/${params.id}/`; return (0, try_catch_wrapper_1.recallRequestTryCatchWrapper)(() => this.client.delete(url)); }); } deleteBotMedia(params) { return __awaiter(this, void 0, void 0, function* () { const url = `${this.botUrl}/${params.id}/delete-media/`; return (0, try_catch_wrapper_1.recallRequestTryCatchWrapper)(() => this.client.post(url)); }); } getBotIntellienge(params) { return __awaiter(this, void 0, void 0, function* () { const url = `${this.botUrl}/${params.id}/intelligence/`; return (0, try_catch_wrapper_1.recallRequestTryCatchWrapper)(() => this.client.get(url)); }); } leaveCall(params) { return __awaiter(this, void 0, void 0, function* () { const url = `${this.botUrl}/${params.id}/leave_call/`; return (0, try_catch_wrapper_1.recallRequestTryCatchWrapper)(() => this.client.post(url)); }); } getBotLogs(params) { return __awaiter(this, void 0, void 0, function* () { const url = `${this.botUrl}/${params.id}/logs/`; return (0, try_catch_wrapper_1.recallRequestTryCatchWrapper)(() => this.client.get(url)); }); } stopRecording(params) { return __awaiter(this, void 0, void 0, function* () { const url = `${this.botUrl}/${params.id}/stop_recording/`; return (0, try_catch_wrapper_1.recallRequestTryCatchWrapper)(() => this.client.post(url)); }); } outputAudio(params) { return __awaiter(this, void 0, void 0, function* () { const url = `${this.botUrl}/${params.id}/output_audio/`; const { id } = params, bodyParams = __rest(params, ["id"]); return (0, try_catch_wrapper_1.recallRequestTryCatchWrapper)(() => this.client.post(url, Object.assign({}, bodyParams), { headers: { "Content-Type": "application/json", }, })); }); } getTranscript(params) { return __awaiter(this, void 0, void 0, function* () { const url = `${this.botUrl}/${params.id}/transcript/`; return (0, try_catch_wrapper_1.recallRequestTryCatchWrapper)(() => this.client.get(url, { params: { enhanced_diarization: params.enhanced_diarization }, })); }); } } exports.Bot = Bot; Bot.instance = null;