UNPKG

recall_sdk

Version:

Node js sdk for the recall ai api

79 lines (78 loc) 3.51 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.CalendarV2 = void 0; const recall_axios_1 = require("../recall-axios"); const try_catch_wrapper_1 = require("../try-catch-wrapper"); class CalendarV2 { constructor({ apiKey, calendarUrl, }) { this.calendarUrl = calendarUrl; this.client = recall_axios_1.RecallAxios.getInstance({ apiKey }); } static getInstance({ apiKey, calendarUrl, }) { if (!CalendarV2.instance) { CalendarV2.instance = new CalendarV2({ apiKey, calendarUrl }); } return CalendarV2.instance; } list(params) { return __awaiter(this, void 0, void 0, function* () { const url = this.calendarUrl; 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.calendarUrl; return (0, try_catch_wrapper_1.recallRequestTryCatchWrapper)(() => this.client.post(url, Object.assign({}, params), { headers: { "Content-Type": "application/json", }, })); }); } retrieve(params) { return __awaiter(this, void 0, void 0, function* () { const url = `${this.calendarUrl}/${params.id}`; return (0, try_catch_wrapper_1.recallRequestTryCatchWrapper)(() => this.client.get(url)); }); } delete(params) { return __awaiter(this, void 0, void 0, function* () { const url = `${this.calendarUrl}/${params.id}/`; return (0, try_catch_wrapper_1.recallRequestTryCatchWrapper)(() => this.client.delete(url)); }); } update(params) { return __awaiter(this, void 0, void 0, function* () { const { id } = params, updateData = __rest(params, ["id"]); const url = `${this.calendarUrl}/${id}/`; return (0, try_catch_wrapper_1.recallRequestTryCatchWrapper)(() => this.client.patch(url, Object.assign({}, updateData), { headers: { "Content-Type": "application/json", }, })); }); } } exports.CalendarV2 = CalendarV2; CalendarV2.instance = null;