node-calendly
Version:
Node module to access calendly api.
76 lines • 3.32 kB
JavaScript
;
/******************************************
* Author : Dr. Sebastian Herden
* Created On : Fri Sep 16 2022
*******************************************/
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 __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ActivityLog_1 = __importDefault(require("./endpoints/ActivityLog"));
const DataCompliance_1 = __importDefault(require("./endpoints/DataCompliance"));
const EventTypes_1 = __importDefault(require("./endpoints/EventTypes"));
const ScheduledEvents_1 = __importDefault(require("./endpoints/ScheduledEvents"));
const Users_1 = __importDefault(require("./endpoints/Users"));
/**
* The gateway to the Calendly API.
* @export
* @class Calendly
* @see https://developer.calendly.com/api-docs/d7755e2f9e5fe-calendly-api
* @implements {OrganizationProvider}
* @implements {MeProvider}
*/
class Calendly {
/**
* Creates an instance of Calendly. After creation you can use the endpoints to access the API.
* @param ACCESS_TOKEN The access token to use for the API calls.
* @memberof Calendly
*/
constructor(ACCESS_TOKEN, params) {
this.ACCESS_TOKEN = ACCESS_TOKEN;
this.users = new Users_1.default(this.ACCESS_TOKEN, params);
this.activityLog = new ActivityLog_1.default(this.ACCESS_TOKEN, this, params);
this.dataCompliance = new DataCompliance_1.default(this.ACCESS_TOKEN, params);
this.eventTypes = new EventTypes_1.default(this.ACCESS_TOKEN, this, this, params);
this.scheduledEvents = new ScheduledEvents_1.default(this.ACCESS_TOKEN, params);
}
/**
* Get the current user.
* @returns {Promise<string>} The URI of the current user.
*/
getMe() {
return __awaiter(this, void 0, void 0, function* () {
const user = yield this.users.getCurrentUser();
return user.uri;
});
}
/**
* Get the organization of the current user.
* @returns {Promise<string>} The URI of the current organization.
*/
getOrganizationUri() {
return __awaiter(this, void 0, void 0, function* () {
const user = yield this.users.getCurrentUser();
return user.current_organization;
});
}
/**
* Get the uuid from a URI.
* @param resourceUri The URI of the resource.
* @returns The UUID of the resource.
*/
static getUuidFromUri(resourceUri) {
return resourceUri.split('/').pop();
}
}
exports.default = Calendly;
//# sourceMappingURL=Calendly.js.map