/*
 * WARNING: This is a generated file. Do not modify directly.
 * Any changes made to this file will be overwritten.
 * 
 * Generated on: 2024-07-05
 * Generated by: TELEports tlparser.py
 * 
 * For any modifications, please edit the source templates and regenerate this file.
 */
    
#include "qtdmessagechatsetmessageautodeletetime.h"

#include <QJsonObject>
#include <QJsonArray>

#include "utils/i18n.h"

QTdMessageChatSetMessageAutoDeleteTime::QTdMessageChatSetMessageAutoDeleteTime(QObject *parent)
    : QTdMessageContent(parent)
{
    setType(MESSAGE_CHAT_SET_MESSAGE_AUTO_DELETE_TIME);
}

QTdMessageChatSetMessageAutoDeleteTime::QTdMessageChatSetMessageAutoDeleteTime(QObject *parent, qint32 messageAutoDeleteTime_, qint64 fromUserId_)
    :         m_messageAutoDeleteTime(messageAutoDeleteTime_),
        m_fromUserId(fromUserId_) {
}

qint32 QTdMessageChatSetMessageAutoDeleteTime::messageAutoDeleteTime() const {
    return m_messageAutoDeleteTime;
}

void QTdMessageChatSetMessageAutoDeleteTime::setMessageAutoDeleteTime(qint32 value) {
    if (m_messageAutoDeleteTime != value) {
        m_messageAutoDeleteTime = value;
        emit dataChanged();
    }
}

qint64 QTdMessageChatSetMessageAutoDeleteTime::fromUserId() const {
    return m_fromUserId;
}

void QTdMessageChatSetMessageAutoDeleteTime::setFromUserId(qint64 value) {
    if (m_fromUserId != value) {
        m_fromUserId = value;
        emit dataChanged();
    }
}

QJsonObject QTdMessageChatSetMessageAutoDeleteTime::marshalJson() {
    return QJsonObject{
        { "@type", QTdObject::typeString() },
        { "message_auto_delete_time", m_messageAutoDeleteTime },
        { "from_user_id", m_fromUserId }
    };
}

void QTdMessageChatSetMessageAutoDeleteTime::unmarshalJson(const QJsonObject &json) {
    QJsonObject jsonObj;
    QJsonArray jsonArray;

    QTdMessageContent::unmarshalJson(json);
    m_messageAutoDeleteTime = json["message_auto_delete_time"].toInt();
    m_fromUserId = json["from_user_id"].toVariant().toLongLong();
    
    m_typeText = gettext("Self-destruct timer was set");
    emit dataChanged();
}
