Source: index.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ZoomMeetingAPI = void 0;
const axios_1 = require("axios");
const jwt = require("jsonwebtoken");
const meetings_1 = require("./functions/meetings");
const registrants_1 = require("./functions/registrants");
const logger_1 = require("./utils/logger");
const users_1 = require("./functions/users");
/**
 * Zoom Meeting Api
 */
class ZoomMeetingAPI {
    /**
     * Create a zoom jwt app and get your credentials
     * @param {string} APISectret - zoom api secret
     * @param {string} apiKey - zoom api key
     * @param {number} logLevel - value should be from 0-4
     */
    constructor(APISectret, apiKey, logLevel = 0) {
        this.zoomIss = apiKey;
        this.zoomToken = APISectret;
        this.meetingFunctions = new meetings_1.Meetings(this.http);
        this.registrantFunctions = new registrants_1.Registrants(this.http);
        this.usersFunctions = new users_1.Users(this.http);
        logger_1.logger().setLogLevel(logLevel);
    }
    get http() {
        if (!this._axiosInstance) {
            const payload = {
                iss: this.zoomIss,
                exp: new Date().getTime() + 1000 * 60,
            };
            const token = jwt.sign(payload, this.zoomToken);
            const headers = {
                Authorization: `Bearer ${token}`,
                'Content-Type': 'application/json',
            };
            this._axiosInstance = axios_1.default.create({
                baseURL: 'https://api.zoom.us/v2',
                headers,
                validateStatus: () => true,
            });
        }
        return this._axiosInstance;
    }
}
exports.ZoomMeetingAPI = ZoomMeetingAPI;