"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.smsErrorToActivityEvent = exports.isSmsError = void 0;
const isSmsError = (error) => {
    return ('data' in error &&
        'details' in error.data &&
        typeof error.data.details === 'string' &&
        'errorCode' in error.data);
};
exports.isSmsError = isSmsError;
const smsErrorToActivityEvent = (error) => {
    var _a;
    if (((_a = error.data.messages) === null || _a === void 0 ? void 0 : _a.length) > 0) {
        return error.data.messages.map((errorItem) => {
            const errorCode = errorItem.messageErrorCode;
            const errorDetails = errorItem.messageDetails;
            const message = `(${errorCode}) ${errorDetails}`;
            return {
                date: new Date().toISOString(),
                text: { en: message },
                error: {
                    category: 'SERVER_ERROR',
                    message,
                },
            };
        });
    }
    const errorCode = error.data.errorCode;
    const errorDetails = error.data.details;
    const message = `(${errorCode}) ${errorDetails}`;
    return [
        {
            date: new Date().toISOString(),
            text: { en: message },
            error: {
                category: 'SERVER_ERROR',
                message,
            },
        },
    ];
};
exports.smsErrorToActivityEvent = smsErrorToActivityEvent;
//# sourceMappingURL=error.js.map