UNPKG

event-app-api

Version:

Package for easy access to Event App API

37 lines (36 loc) 2.08 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()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports._unblockEvent = exports._blockEvent = exports._fetchCalendarEvents = void 0; const api_1 = require("../../utils/api"); const base_1 = require("../../utils/base"); const _fetchCalendarEvents = (basePath, token) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const calendarEvents = yield (0, api_1.getRequest)(`${base.USERS}/agenda`, token); return (calendarEvents === null || calendarEvents === void 0 ? void 0 : calendarEvents.data) || calendarEvents; }); exports._fetchCalendarEvents = _fetchCalendarEvents; const _blockEvent = (basePath, token, event, startDate, endDate) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const response = yield (0, api_1.postRequest)(`${base.USERS}/agenda/block`, { event, start_date: startDate, end_date: endDate, }, token); return response; }); exports._blockEvent = _blockEvent; const _unblockEvent = (basePath, token, availabilityId) => __awaiter(void 0, void 0, void 0, function* () { const base = (0, base_1.getBasePath)(basePath); const response = yield (0, api_1.deleteRequest)(`${base.USERS}/agenda/block/${availabilityId}`, null, token); return response; }); exports._unblockEvent = _unblockEvent;