"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());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getActiveRecording = exports.stopRecording = exports.startRecording = void 0;
const config_1 = __importDefault(require("./config"));
const startRecording = (options) => __awaiter(void 0, void 0, void 0, function* () {
    const { authToken, organizationId, roomName } = options;
    const response = yield fetch(`${config_1.default.apiBase}/v1/organizations/${organizationId}/rooms/${roomName}/recording`, {
        method: 'POST',
        headers: {
            Accept: 'application/json',
            'Content-Type': 'application/json',
            Authorization: `Bearer ${authToken}`,
        },
    });
    if (response.status !== 201) {
        throw new Error('Recording failed to start');
    }
    return response.json();
});
exports.startRecording = startRecording;
const stopRecording = (options) => __awaiter(void 0, void 0, void 0, function* () {
    const { authToken, organizationId, roomName, recordingId } = options;
    const response = yield fetch(`${config_1.default.apiBase}/v1/organizations/${organizationId}/rooms/${roomName}/recordings/${recordingId}`, {
        method: 'PUT',
        body: JSON.stringify({ recordingAction: 'stop' }),
        headers: {
            Accept: 'application/json',
            'Content-Type': 'application/json',
            Authorization: `Bearer ${authToken}`,
        },
    });
    if (response.status !== 201) {
        throw new Error('Recording failed to stop');
    }
    return response.json();
});
exports.stopRecording = stopRecording;
const getActiveRecording = (options) => __awaiter(void 0, void 0, void 0, function* () {
    const { authToken, organizationId, roomName } = options;
    const response = yield fetch(`${config_1.default.apiBase}/v1/organizations/${organizationId}/rooms/${roomName}/active-recording`, {
        method: 'GET',
        headers: {
            Accept: 'application/json',
            'Content-Type': 'application/json',
            Authorization: `Bearer ${authToken}`,
        },
    });
    return response.json();
});
exports.getActiveRecording = getActiveRecording;
//# sourceMappingURL=recording.js.map