var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { AppApiHostname } from "../EnvironmentConfig";
import ClusterKeyAuthorization from "../Middleware/ClusterKeyAuthorization";
import BaseService from "./BaseService";
import Protocol from "../../Types/API/Protocol";
import Route from "../../Types/API/Route";
import URL from "../../Types/API/URL";
import API from "../../Utils/API";
import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
export class CallService extends BaseService {
    constructor() {
        super();
    }
    async makeCall(callRequest, options) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
        const body = {
            callRequest: callRequest,
            projectId: (_a = options.projectId) === null || _a === void 0 ? void 0 : _a.toString(),
            isSensitive: options.isSensitive,
            userOnCallLogTimelineId: (_b = options.userOnCallLogTimelineId) === null || _b === void 0 ? void 0 : _b.toString(),
            customTwilioConfig: options.customTwilioConfig
                ? {
                    accountSid: options.customTwilioConfig.accountSid,
                    authToken: options.customTwilioConfig.authToken,
                    primaryPhoneNumber: options.customTwilioConfig.primaryPhoneNumber.toString(),
                    secondaryPhoneNumbers: (_c = options.customTwilioConfig.secondaryPhoneNumbers) === null || _c === void 0 ? void 0 : _c.toString(),
                }
                : undefined,
            incidentId: (_d = options.incidentId) === null || _d === void 0 ? void 0 : _d.toString(),
            alertId: (_e = options.alertId) === null || _e === void 0 ? void 0 : _e.toString(),
            alertEpisodeId: (_f = options.alertEpisodeId) === null || _f === void 0 ? void 0 : _f.toString(),
            monitorId: (_g = options.monitorId) === null || _g === void 0 ? void 0 : _g.toString(),
            scheduledMaintenanceId: (_h = options.scheduledMaintenanceId) === null || _h === void 0 ? void 0 : _h.toString(),
            statusPageId: (_j = options.statusPageId) === null || _j === void 0 ? void 0 : _j.toString(),
            statusPageAnnouncementId: (_k = options.statusPageAnnouncementId) === null || _k === void 0 ? void 0 : _k.toString(),
            userId: (_l = options.userId) === null || _l === void 0 ? void 0 : _l.toString(),
            onCallPolicyId: (_m = options.onCallPolicyId) === null || _m === void 0 ? void 0 : _m.toString(),
            onCallPolicyEscalationRuleId: (_o = options.onCallPolicyEscalationRuleId) === null || _o === void 0 ? void 0 : _o.toString(),
            teamId: (_p = options.teamId) === null || _p === void 0 ? void 0 : _p.toString(),
            onCallDutyPolicyExecutionLogTimelineId: (_q = options.onCallDutyPolicyExecutionLogTimelineId) === null || _q === void 0 ? void 0 : _q.toString(),
            onCallScheduleId: (_r = options.onCallScheduleId) === null || _r === void 0 ? void 0 : _r.toString(),
        };
        return await API.post({
            url: new URL(Protocol.HTTP, AppApiHostname, new Route("/api/notification/call/make-call")),
            data: body,
            headers: Object.assign({}, ClusterKeyAuthorization.getClusterKeyHeaders()),
        });
    }
}
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", Promise)
], CallService.prototype, "makeCall", null);
export default new CallService();
//# sourceMappingURL=CallService.js.map