"use strict";
/**
 * This file was auto-generated by Fern from our API Definition.
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
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 __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tickets = void 0;
const environments = __importStar(require("../../../../../../environments"));
const core = __importStar(require("../../../../../../core"));
const url_search_params_1 = __importDefault(require("@ungap/url-search-params"));
const url_join_1 = __importDefault(require("url-join"));
const serializers = __importStar(require("../../../../../../serialization"));
const errors = __importStar(require("../../../../../../errors"));
class Tickets {
    constructor(_options) {
        this._options = _options;
    }
    /**
     * Returns a list of `Ticket` objects.
     */
    list(request = {}, requestOptions) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            const { accountId, assigneeIds, collectionIds, completedAfter, completedBefore, contactId, createdAfter, createdBefore, cursor, dueAfter, dueBefore, expand, includeDeletedData, includeRemoteData, includeRemoteFields, modifiedAfter, modifiedBefore, pageSize, parentTicketId, priority, projectId, remoteCreatedAfter, remoteCreatedBefore, remoteFields, remoteId, remoteUpdatedAfter, remoteUpdatedBefore, showEnumOrigins, status, tags, ticketType, } = request;
            const _queryParams = new url_search_params_1.default();
            if (accountId != null) {
                _queryParams.append("account_id", accountId);
            }
            if (assigneeIds != null) {
                _queryParams.append("assignee_ids", assigneeIds);
            }
            if (collectionIds != null) {
                _queryParams.append("collection_ids", collectionIds);
            }
            if (completedAfter != null) {
                _queryParams.append("completed_after", completedAfter.toISOString());
            }
            if (completedBefore != null) {
                _queryParams.append("completed_before", completedBefore.toISOString());
            }
            if (contactId != null) {
                _queryParams.append("contact_id", contactId);
            }
            if (createdAfter != null) {
                _queryParams.append("created_after", createdAfter.toISOString());
            }
            if (createdBefore != null) {
                _queryParams.append("created_before", createdBefore.toISOString());
            }
            if (cursor != null) {
                _queryParams.append("cursor", cursor);
            }
            if (dueAfter != null) {
                _queryParams.append("due_after", dueAfter.toISOString());
            }
            if (dueBefore != null) {
                _queryParams.append("due_before", dueBefore.toISOString());
            }
            if (expand != null) {
                _queryParams.append("expand", expand);
            }
            if (includeDeletedData != null) {
                _queryParams.append("include_deleted_data", includeDeletedData.toString());
            }
            if (includeRemoteData != null) {
                _queryParams.append("include_remote_data", includeRemoteData.toString());
            }
            if (includeRemoteFields != null) {
                _queryParams.append("include_remote_fields", includeRemoteFields.toString());
            }
            if (modifiedAfter != null) {
                _queryParams.append("modified_after", modifiedAfter.toISOString());
            }
            if (modifiedBefore != null) {
                _queryParams.append("modified_before", modifiedBefore.toISOString());
            }
            if (pageSize != null) {
                _queryParams.append("page_size", pageSize.toString());
            }
            if (parentTicketId != null) {
                _queryParams.append("parent_ticket_id", parentTicketId);
            }
            if (priority != null) {
                _queryParams.append("priority", priority);
            }
            if (projectId != null) {
                _queryParams.append("project_id", projectId);
            }
            if (remoteCreatedAfter != null) {
                _queryParams.append("remote_created_after", remoteCreatedAfter.toISOString());
            }
            if (remoteCreatedBefore != null) {
                _queryParams.append("remote_created_before", remoteCreatedBefore.toISOString());
            }
            if (remoteFields != null) {
                _queryParams.append("remote_fields", remoteFields);
            }
            if (remoteId != null) {
                _queryParams.append("remote_id", remoteId);
            }
            if (remoteUpdatedAfter != null) {
                _queryParams.append("remote_updated_after", remoteUpdatedAfter.toISOString());
            }
            if (remoteUpdatedBefore != null) {
                _queryParams.append("remote_updated_before", remoteUpdatedBefore.toISOString());
            }
            if (showEnumOrigins != null) {
                _queryParams.append("show_enum_origins", showEnumOrigins);
            }
            if (status != null) {
                _queryParams.append("status", status);
            }
            if (tags != null) {
                _queryParams.append("tags", tags);
            }
            if (ticketType != null) {
                _queryParams.append("ticket_type", ticketType);
            }
            const _response = yield core.fetcher({
                url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.MergeEnvironment.Production, "api/ticketing/v1/tickets"),
                method: "GET",
                headers: {
                    Authorization: yield this._getAuthorizationHeader(),
                    "X-Account-Token": (yield core.Supplier.get(this._options.accountToken)) != null
                        ? yield core.Supplier.get(this._options.accountToken)
                        : undefined,
                    "X-Fern-Language": "JavaScript",
                    "X-Fern-SDK-Name": "@mergeapi/merge-node-client",
                    "X-Fern-SDK-Version": "1.0.0",
                },
                contentType: "application/json",
                queryParameters: _queryParams,
                timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
            });
            if (_response.ok) {
                return yield serializers.ticketing.PaginatedTicketList.parseOrThrow(_response.body, {
                    unrecognizedObjectKeys: "passthrough",
                    allowUnrecognizedUnionMembers: true,
                    allowUnrecognizedEnumValues: true,
                    breadcrumbsPrefix: ["response"],
                });
            }
            if (_response.error.reason === "status-code") {
                throw new errors.MergeError({
                    statusCode: _response.error.statusCode,
                    body: _response.error.body,
                });
            }
            switch (_response.error.reason) {
                case "non-json":
                    throw new errors.MergeError({
                        statusCode: _response.error.statusCode,
                        body: _response.error.rawBody,
                    });
                case "timeout":
                    throw new errors.MergeTimeoutError();
                case "unknown":
                    throw new errors.MergeError({
                        message: _response.error.errorMessage,
                    });
            }
        });
    }
    /**
     * Creates a `Ticket` object with the given values.
     */
    create(request, requestOptions) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            const { isDebugMode, runAsync } = request, _body = __rest(request, ["isDebugMode", "runAsync"]);
            const _queryParams = new url_search_params_1.default();
            if (isDebugMode != null) {
                _queryParams.append("is_debug_mode", isDebugMode.toString());
            }
            if (runAsync != null) {
                _queryParams.append("run_async", runAsync.toString());
            }
            const _response = yield core.fetcher({
                url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.MergeEnvironment.Production, "api/ticketing/v1/tickets"),
                method: "POST",
                headers: {
                    Authorization: yield this._getAuthorizationHeader(),
                    "X-Account-Token": (yield core.Supplier.get(this._options.accountToken)) != null
                        ? yield core.Supplier.get(this._options.accountToken)
                        : undefined,
                    "X-Fern-Language": "JavaScript",
                    "X-Fern-SDK-Name": "@mergeapi/merge-node-client",
                    "X-Fern-SDK-Version": "1.0.0",
                },
                contentType: "application/json",
                queryParameters: _queryParams,
                body: yield serializers.ticketing.TicketEndpointRequest.jsonOrThrow(_body, {
                    unrecognizedObjectKeys: "strip",
                }),
                timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
            });
            if (_response.ok) {
                return yield serializers.ticketing.TicketResponse.parseOrThrow(_response.body, {
                    unrecognizedObjectKeys: "passthrough",
                    allowUnrecognizedUnionMembers: true,
                    allowUnrecognizedEnumValues: true,
                    breadcrumbsPrefix: ["response"],
                });
            }
            if (_response.error.reason === "status-code") {
                throw new errors.MergeError({
                    statusCode: _response.error.statusCode,
                    body: _response.error.body,
                });
            }
            switch (_response.error.reason) {
                case "non-json":
                    throw new errors.MergeError({
                        statusCode: _response.error.statusCode,
                        body: _response.error.rawBody,
                    });
                case "timeout":
                    throw new errors.MergeTimeoutError();
                case "unknown":
                    throw new errors.MergeError({
                        message: _response.error.errorMessage,
                    });
            }
        });
    }
    /**
     * Returns a `Ticket` object with the given `id`.
     */
    retrieve(id, request = {}, requestOptions) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            const { expand, includeRemoteData, includeRemoteFields, remoteFields, showEnumOrigins } = request;
            const _queryParams = new url_search_params_1.default();
            if (expand != null) {
                _queryParams.append("expand", expand);
            }
            if (includeRemoteData != null) {
                _queryParams.append("include_remote_data", includeRemoteData.toString());
            }
            if (includeRemoteFields != null) {
                _queryParams.append("include_remote_fields", includeRemoteFields.toString());
            }
            if (remoteFields != null) {
                _queryParams.append("remote_fields", remoteFields);
            }
            if (showEnumOrigins != null) {
                _queryParams.append("show_enum_origins", showEnumOrigins);
            }
            const _response = yield core.fetcher({
                url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.MergeEnvironment.Production, `api/ticketing/v1/tickets/${id}`),
                method: "GET",
                headers: {
                    Authorization: yield this._getAuthorizationHeader(),
                    "X-Account-Token": (yield core.Supplier.get(this._options.accountToken)) != null
                        ? yield core.Supplier.get(this._options.accountToken)
                        : undefined,
                    "X-Fern-Language": "JavaScript",
                    "X-Fern-SDK-Name": "@mergeapi/merge-node-client",
                    "X-Fern-SDK-Version": "1.0.0",
                },
                contentType: "application/json",
                queryParameters: _queryParams,
                timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
            });
            if (_response.ok) {
                return yield serializers.ticketing.Ticket.parseOrThrow(_response.body, {
                    unrecognizedObjectKeys: "passthrough",
                    allowUnrecognizedUnionMembers: true,
                    allowUnrecognizedEnumValues: true,
                    breadcrumbsPrefix: ["response"],
                });
            }
            if (_response.error.reason === "status-code") {
                throw new errors.MergeError({
                    statusCode: _response.error.statusCode,
                    body: _response.error.body,
                });
            }
            switch (_response.error.reason) {
                case "non-json":
                    throw new errors.MergeError({
                        statusCode: _response.error.statusCode,
                        body: _response.error.rawBody,
                    });
                case "timeout":
                    throw new errors.MergeTimeoutError();
                case "unknown":
                    throw new errors.MergeError({
                        message: _response.error.errorMessage,
                    });
            }
        });
    }
    /**
     * Updates a `Ticket` object with the given `id`.
     */
    partialUpdate(id, request, requestOptions) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            const { isDebugMode, runAsync } = request, _body = __rest(request, ["isDebugMode", "runAsync"]);
            const _queryParams = new url_search_params_1.default();
            if (isDebugMode != null) {
                _queryParams.append("is_debug_mode", isDebugMode.toString());
            }
            if (runAsync != null) {
                _queryParams.append("run_async", runAsync.toString());
            }
            const _response = yield core.fetcher({
                url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.MergeEnvironment.Production, `api/ticketing/v1/tickets/${id}`),
                method: "PATCH",
                headers: {
                    Authorization: yield this._getAuthorizationHeader(),
                    "X-Account-Token": (yield core.Supplier.get(this._options.accountToken)) != null
                        ? yield core.Supplier.get(this._options.accountToken)
                        : undefined,
                    "X-Fern-Language": "JavaScript",
                    "X-Fern-SDK-Name": "@mergeapi/merge-node-client",
                    "X-Fern-SDK-Version": "1.0.0",
                },
                contentType: "application/json",
                queryParameters: _queryParams,
                body: yield serializers.ticketing.PatchedTicketEndpointRequest.jsonOrThrow(_body, {
                    unrecognizedObjectKeys: "strip",
                }),
                timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
            });
            if (_response.ok) {
                return yield serializers.ticketing.TicketResponse.parseOrThrow(_response.body, {
                    unrecognizedObjectKeys: "passthrough",
                    allowUnrecognizedUnionMembers: true,
                    allowUnrecognizedEnumValues: true,
                    breadcrumbsPrefix: ["response"],
                });
            }
            if (_response.error.reason === "status-code") {
                throw new errors.MergeError({
                    statusCode: _response.error.statusCode,
                    body: _response.error.body,
                });
            }
            switch (_response.error.reason) {
                case "non-json":
                    throw new errors.MergeError({
                        statusCode: _response.error.statusCode,
                        body: _response.error.rawBody,
                    });
                case "timeout":
                    throw new errors.MergeTimeoutError();
                case "unknown":
                    throw new errors.MergeError({
                        message: _response.error.errorMessage,
                    });
            }
        });
    }
    /**
     * Returns a list of `User` objects.
     */
    collaboratorsList(parentId, request = {}, requestOptions) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            const { cursor, expand, includeDeletedData, includeRemoteData, pageSize } = request;
            const _queryParams = new url_search_params_1.default();
            if (cursor != null) {
                _queryParams.append("cursor", cursor);
            }
            if (expand != null) {
                _queryParams.append("expand", expand);
            }
            if (includeDeletedData != null) {
                _queryParams.append("include_deleted_data", includeDeletedData.toString());
            }
            if (includeRemoteData != null) {
                _queryParams.append("include_remote_data", includeRemoteData.toString());
            }
            if (pageSize != null) {
                _queryParams.append("page_size", pageSize.toString());
            }
            const _response = yield core.fetcher({
                url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.MergeEnvironment.Production, `api/ticketing/v1/tickets/${parentId}/collaborators`),
                method: "GET",
                headers: {
                    Authorization: yield this._getAuthorizationHeader(),
                    "X-Account-Token": (yield core.Supplier.get(this._options.accountToken)) != null
                        ? yield core.Supplier.get(this._options.accountToken)
                        : undefined,
                    "X-Fern-Language": "JavaScript",
                    "X-Fern-SDK-Name": "@mergeapi/merge-node-client",
                    "X-Fern-SDK-Version": "1.0.0",
                },
                contentType: "application/json",
                queryParameters: _queryParams,
                timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
            });
            if (_response.ok) {
                return yield serializers.ticketing.PaginatedUserList.parseOrThrow(_response.body, {
                    unrecognizedObjectKeys: "passthrough",
                    allowUnrecognizedUnionMembers: true,
                    allowUnrecognizedEnumValues: true,
                    breadcrumbsPrefix: ["response"],
                });
            }
            if (_response.error.reason === "status-code") {
                throw new errors.MergeError({
                    statusCode: _response.error.statusCode,
                    body: _response.error.body,
                });
            }
            switch (_response.error.reason) {
                case "non-json":
                    throw new errors.MergeError({
                        statusCode: _response.error.statusCode,
                        body: _response.error.rawBody,
                    });
                case "timeout":
                    throw new errors.MergeTimeoutError();
                case "unknown":
                    throw new errors.MergeError({
                        message: _response.error.errorMessage,
                    });
            }
        });
    }
    /**
     * Returns metadata for `Ticket` PATCHs.
     */
    metaPatchRetrieve(id, requestOptions) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            const _response = yield core.fetcher({
                url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.MergeEnvironment.Production, `api/ticketing/v1/tickets/meta/patch/${id}`),
                method: "GET",
                headers: {
                    Authorization: yield this._getAuthorizationHeader(),
                    "X-Account-Token": (yield core.Supplier.get(this._options.accountToken)) != null
                        ? yield core.Supplier.get(this._options.accountToken)
                        : undefined,
                    "X-Fern-Language": "JavaScript",
                    "X-Fern-SDK-Name": "@mergeapi/merge-node-client",
                    "X-Fern-SDK-Version": "1.0.0",
                },
                contentType: "application/json",
                timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
            });
            if (_response.ok) {
                return yield serializers.ticketing.MetaResponse.parseOrThrow(_response.body, {
                    unrecognizedObjectKeys: "passthrough",
                    allowUnrecognizedUnionMembers: true,
                    allowUnrecognizedEnumValues: true,
                    breadcrumbsPrefix: ["response"],
                });
            }
            if (_response.error.reason === "status-code") {
                throw new errors.MergeError({
                    statusCode: _response.error.statusCode,
                    body: _response.error.body,
                });
            }
            switch (_response.error.reason) {
                case "non-json":
                    throw new errors.MergeError({
                        statusCode: _response.error.statusCode,
                        body: _response.error.rawBody,
                    });
                case "timeout":
                    throw new errors.MergeTimeoutError();
                case "unknown":
                    throw new errors.MergeError({
                        message: _response.error.errorMessage,
                    });
            }
        });
    }
    /**
     * Returns metadata for `Ticket` POSTs.
     */
    metaPostRetrieve(requestOptions) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            const _response = yield core.fetcher({
                url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.MergeEnvironment.Production, "api/ticketing/v1/tickets/meta/post"),
                method: "GET",
                headers: {
                    Authorization: yield this._getAuthorizationHeader(),
                    "X-Account-Token": (yield core.Supplier.get(this._options.accountToken)) != null
                        ? yield core.Supplier.get(this._options.accountToken)
                        : undefined,
                    "X-Fern-Language": "JavaScript",
                    "X-Fern-SDK-Name": "@mergeapi/merge-node-client",
                    "X-Fern-SDK-Version": "1.0.0",
                },
                contentType: "application/json",
                timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
            });
            if (_response.ok) {
                return yield serializers.ticketing.MetaResponse.parseOrThrow(_response.body, {
                    unrecognizedObjectKeys: "passthrough",
                    allowUnrecognizedUnionMembers: true,
                    allowUnrecognizedEnumValues: true,
                    breadcrumbsPrefix: ["response"],
                });
            }
            if (_response.error.reason === "status-code") {
                throw new errors.MergeError({
                    statusCode: _response.error.statusCode,
                    body: _response.error.body,
                });
            }
            switch (_response.error.reason) {
                case "non-json":
                    throw new errors.MergeError({
                        statusCode: _response.error.statusCode,
                        body: _response.error.rawBody,
                    });
                case "timeout":
                    throw new errors.MergeTimeoutError();
                case "unknown":
                    throw new errors.MergeError({
                        message: _response.error.errorMessage,
                    });
            }
        });
    }
    /**
     * Returns a list of `RemoteFieldClass` objects.
     */
    remoteFieldClassesList(request = {}, requestOptions) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            const { cursor, includeDeletedData, includeRemoteData, pageSize } = request;
            const _queryParams = new url_search_params_1.default();
            if (cursor != null) {
                _queryParams.append("cursor", cursor);
            }
            if (includeDeletedData != null) {
                _queryParams.append("include_deleted_data", includeDeletedData.toString());
            }
            if (includeRemoteData != null) {
                _queryParams.append("include_remote_data", includeRemoteData.toString());
            }
            if (pageSize != null) {
                _queryParams.append("page_size", pageSize.toString());
            }
            const _response = yield core.fetcher({
                url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.MergeEnvironment.Production, "api/ticketing/v1/tickets/remote-field-classes"),
                method: "GET",
                headers: {
                    Authorization: yield this._getAuthorizationHeader(),
                    "X-Account-Token": (yield core.Supplier.get(this._options.accountToken)) != null
                        ? yield core.Supplier.get(this._options.accountToken)
                        : undefined,
                    "X-Fern-Language": "JavaScript",
                    "X-Fern-SDK-Name": "@mergeapi/merge-node-client",
                    "X-Fern-SDK-Version": "1.0.0",
                },
                contentType: "application/json",
                queryParameters: _queryParams,
                timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
            });
            if (_response.ok) {
                return yield serializers.ticketing.PaginatedRemoteFieldClassList.parseOrThrow(_response.body, {
                    unrecognizedObjectKeys: "passthrough",
                    allowUnrecognizedUnionMembers: true,
                    allowUnrecognizedEnumValues: true,
                    breadcrumbsPrefix: ["response"],
                });
            }
            if (_response.error.reason === "status-code") {
                throw new errors.MergeError({
                    statusCode: _response.error.statusCode,
                    body: _response.error.body,
                });
            }
            switch (_response.error.reason) {
                case "non-json":
                    throw new errors.MergeError({
                        statusCode: _response.error.statusCode,
                        body: _response.error.rawBody,
                    });
                case "timeout":
                    throw new errors.MergeTimeoutError();
                case "unknown":
                    throw new errors.MergeError({
                        message: _response.error.errorMessage,
                    });
            }
        });
    }
    _getAuthorizationHeader() {
        return __awaiter(this, void 0, void 0, function* () {
            return `Bearer ${yield core.Supplier.get(this._options.apiKey)}`;
        });
    }
}
exports.Tickets = Tickets;
