"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractHostEmail = exports.extractScheduledEventTypeId = exports.extractScheduledEventId = void 0;
/* eslint-disable @typescript-eslint/naming-convention */
const lodash_1 = require("lodash");
/**
 * https://api.calendly.com/scheduled_events/GBGBDCAADAEDCRZ2 => GBGBDCAADAEDCRZ2
 * @param param0
 * @returns
 */
const extractScheduledEventId = ({ uri }) => {
    var _a;
    const scheduledEventId = (_a = /scheduled_events\/(.+)/.exec(uri)) === null || _a === void 0 ? void 0 : _a[1];
    if ((0, lodash_1.isNil)(scheduledEventId)) {
        throw new Error(`Could not parse scheduled event id from uri ${uri}`);
    }
    return scheduledEventId;
};
exports.extractScheduledEventId = extractScheduledEventId;
/**
 * https://api.calendly.com/event_types/GBGBDCAADAEDCRZ2 => GBGBDCAADAEDCRZ2
 * @param param0
 * @returns
 */
const extractScheduledEventTypeId = ({ event_type, }) => {
    var _a;
    const scheduledEventTypeId = (_a = /event_types\/(.+)/.exec(event_type)) === null || _a === void 0 ? void 0 : _a[1];
    if ((0, lodash_1.isNil)(scheduledEventTypeId)) {
        throw new Error(`Could not parse scheduled event type id from uri ${event_type}`);
    }
    return scheduledEventTypeId;
};
exports.extractScheduledEventTypeId = extractScheduledEventTypeId;
const extractHostEmail = ({ event_memberships, }) => {
    return event_memberships.length > 0 ? event_memberships[0].user_email : '';
};
exports.extractHostEmail = extractHostEmail;
//# sourceMappingURL=helpers.js.map