UNPKG

ade-planning-api

Version:

An unofficial API wrapper for ADE Planning from Adesoft

65 lines (64 loc) 2.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ADEPlanningAPI = void 0; const fetcher_1 = require("./utils/fetcher"); const projectService_1 = require("./services/projectService"); const eventService_1 = require("./services/eventService"); const resourceService_1 = require("./services/resourceService"); class ADEPlanningAPI { fetcher; /** * Initializes a new instance of the ADEPlanningAPI class. * @param baseUrl The base URL of the ADE instance. * @returns A new instance of the ADEPlanningAPI class. */ constructor(baseUrl) { this.fetcher = new fetcher_1.ADEFetcher(baseUrl); } /** * Initializes a new session with the API. * @param credentials The credentials to use for authentication. * @returns A promise that resolves when the session is initialized. */ async initializeSession(credentials) { return await this.fetcher.initializeSession(credentials); } /** * Terminates the current session with the API. * @returns A promise that resolves when the session is terminated. */ async terminateSession() { return await this.fetcher.terminateSession(); } /** * Gets the list of projects. * @returns A promise that resolves with the list of projects. */ async getProjects() { return await (0, projectService_1.getProjects)(this.fetcher); } /** * Sets the current project. * @param project The project to set as current. * @returns A promise that resolves when the project is set. */ async setProject(project) { return await (0, projectService_1.setProject)(this.fetcher, project); } /** * Gets the list of events. * @param params The parameters to pass to the API. * @returns A promise that resolves with the list of events. */ async getEvents(params) { return await (0, eventService_1.getEvents)(this.fetcher, params); } /** * @param params The parameters to pass to the API. * @returns A promise that resolves with the list of resources. */ async getResources(params) { return await (0, resourceService_1.getResources)(this.fetcher, params); } } exports.ADEPlanningAPI = ADEPlanningAPI;