/*
 * Copyright (C) 2024 UBPorts Foundation
 *
 * WARNING: This is a generated file. Do not modify directly.
 * Any changes made to this file will be overwritten.
 * 
 * Generated on: 2024-07-26
 * Generated by: TELEports tlparser.py
 * 
 * For any modifications, please edit the source templates and regenerate this file.
 */

#include "qtdchatmemberstatus.h"

#include <QJsonObject>
#include <QJsonArray>

QTdChatMemberStatus::QTdChatMemberStatus(QObject *parent)
    : QTdObject(parent)
{
}

QJsonObject QTdChatMemberStatus::marshalJson() {
    return QJsonObject{
        { "@type", QTdObject::typeString() },

    };
}

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

    QTdObject::unmarshalJson(json);

    emit dataChanged();
}

QTdChatMemberStatusCreator::QTdChatMemberStatusCreator(QObject *parent)
    : QTdChatMemberStatus(parent)
{
    setType(CHAT_MEMBER_STATUS_CREATOR);
}

QTdChatMemberStatusCreator::QTdChatMemberStatusCreator(QObject *parent, QString customTitle_, bool isAnonymous_, bool isMember_)
    : QTdChatMemberStatus(parent),
    m_customTitle(customTitle_),
    m_isAnonymous(isAnonymous_),
    m_isMember(isMember_) {
    setType(CHAT_MEMBER_STATUS_CREATOR);
}

QString QTdChatMemberStatusCreator::customTitle() const {
    return m_customTitle;
}

void QTdChatMemberStatusCreator::setCustomTitle(QString value) {
    if (m_customTitle != value) {
        m_customTitle = value;
        emit dataChanged();
    }
}

bool QTdChatMemberStatusCreator::isAnonymous() const {
    return m_isAnonymous;
}

void QTdChatMemberStatusCreator::setIsAnonymous(bool value) {
    if (m_isAnonymous != value) {
        m_isAnonymous = value;
        emit dataChanged();
    }
}

bool QTdChatMemberStatusCreator::isMember() const {
    return m_isMember;
}

void QTdChatMemberStatusCreator::setIsMember(bool value) {
    if (m_isMember != value) {
        m_isMember = value;
        emit dataChanged();
    }
}

QJsonObject QTdChatMemberStatusCreator::marshalJson() {
    return QJsonObject{
        { "@type", QTdObject::typeString() },
        { "custom_title", m_customTitle },
        { "is_anonymous", m_isAnonymous },
        { "is_member", m_isMember }
    };
}

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

    QTdChatMemberStatus::unmarshalJson(json);
    m_customTitle = json["custom_title"].toString();
    m_isAnonymous = json["is_anonymous"].toBool();
    m_isMember = json["is_member"].toBool();

    emit dataChanged();
}

QTdChatMemberStatusAdministrator::QTdChatMemberStatusAdministrator(QObject *parent)
    : QTdChatMemberStatus(parent)
{
    setType(CHAT_MEMBER_STATUS_ADMIN);
}

QTdChatMemberStatusAdministrator::QTdChatMemberStatusAdministrator(QObject *parent, QString customTitle_, bool canBeEdited_, QTdChatAdministratorRights* rights_)
    : QTdChatMemberStatus(parent),
    m_customTitle(customTitle_),
    m_canBeEdited(canBeEdited_),
    m_rights(rights_) {
    setType(CHAT_MEMBER_STATUS_ADMIN);
}

QString QTdChatMemberStatusAdministrator::customTitle() const {
    return m_customTitle;
}

void QTdChatMemberStatusAdministrator::setCustomTitle(QString value) {
    if (m_customTitle != value) {
        m_customTitle = value;
        emit dataChanged();
    }
}

bool QTdChatMemberStatusAdministrator::canBeEdited() const {
    return m_canBeEdited;
}

void QTdChatMemberStatusAdministrator::setCanBeEdited(bool value) {
    if (m_canBeEdited != value) {
        m_canBeEdited = value;
        emit dataChanged();
    }
}

QTdChatAdministratorRights* QTdChatMemberStatusAdministrator::rights() const {
    return m_rights.data();
}

void QTdChatMemberStatusAdministrator::setRights(QTdChatAdministratorRights* value) {
    if (m_rights.data() != value) {
        m_rights.reset(value);
        emit dataChanged();
    }
}

QJsonObject QTdChatMemberStatusAdministrator::marshalJson() {
    return QJsonObject{
        { "@type", QTdObject::typeString() },
        { "custom_title", m_customTitle },
        { "can_be_edited", m_canBeEdited },
        { "rights", m_rights->marshalJson() }
    };
}

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

    QTdChatMemberStatus::unmarshalJson(json);
    m_customTitle = json["custom_title"].toString();
    m_canBeEdited = json["can_be_edited"].toBool();
    m_rights.reset(new QTdChatAdministratorRights(this));
    m_rights->unmarshalJson(json["rights"].toObject());

    emit dataChanged();
}

QTdChatMemberStatusMember::QTdChatMemberStatusMember(QObject *parent)
    : QTdChatMemberStatus(parent)
{
    setType(CHAT_MEMBER_STATUS_MEMBER);
}

QJsonObject QTdChatMemberStatusMember::marshalJson() {
    return QJsonObject{
        { "@type", QTdObject::typeString() },

    };
}

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

    QTdChatMemberStatus::unmarshalJson(json);

    emit dataChanged();
}

QTdChatMemberStatusRestricted::QTdChatMemberStatusRestricted(QObject *parent)
    : QTdChatMemberStatus(parent)
{
    setType(CHAT_MEMBER_STATUS_RESTRICTED);
}

QTdChatMemberStatusRestricted::QTdChatMemberStatusRestricted(QObject *parent, bool isMember_, qint32 restrictedUntilDate_, QTdChatPermissions* permissions_)
    : QTdChatMemberStatus(parent),
    m_isMember(isMember_),
    m_restrictedUntilDate(restrictedUntilDate_),
    m_permissions(permissions_) {
    setType(CHAT_MEMBER_STATUS_RESTRICTED);
}

bool QTdChatMemberStatusRestricted::isMember() const {
    return m_isMember;
}

void QTdChatMemberStatusRestricted::setIsMember(bool value) {
    if (m_isMember != value) {
        m_isMember = value;
        emit dataChanged();
    }
}

qint32 QTdChatMemberStatusRestricted::restrictedUntilDate() const {
    return m_restrictedUntilDate;
}

void QTdChatMemberStatusRestricted::setRestrictedUntilDate(qint32 value) {
    if (m_restrictedUntilDate != value) {
        m_restrictedUntilDate = value;
        emit dataChanged();
    }
}

QTdChatPermissions* QTdChatMemberStatusRestricted::permissions() const {
    return m_permissions.data();
}

void QTdChatMemberStatusRestricted::setPermissions(QTdChatPermissions* value) {
    if (m_permissions.data() != value) {
        m_permissions.reset(value);
        emit dataChanged();
    }
}

QJsonObject QTdChatMemberStatusRestricted::marshalJson() {
    return QJsonObject{
        { "@type", QTdObject::typeString() },
        { "is_member", m_isMember },
        { "restricted_until_date", m_restrictedUntilDate },
        { "permissions", m_permissions->marshalJson() }
    };
}

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

    QTdChatMemberStatus::unmarshalJson(json);
    m_isMember = json["is_member"].toBool();
    m_restrictedUntilDate = json["restricted_until_date"].toInt();
    m_permissions.reset(new QTdChatPermissions(this));
    m_permissions->unmarshalJson(json["permissions"].toObject());

    emit dataChanged();
}

QTdChatMemberStatusLeft::QTdChatMemberStatusLeft(QObject *parent)
    : QTdChatMemberStatus(parent)
{
    setType(CHAT_MEMBER_STATUS_LEFT);
}

QJsonObject QTdChatMemberStatusLeft::marshalJson() {
    return QJsonObject{
        { "@type", QTdObject::typeString() },

    };
}

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

    QTdChatMemberStatus::unmarshalJson(json);

    emit dataChanged();
}

QTdChatMemberStatusBanned::QTdChatMemberStatusBanned(QObject *parent)
    : QTdChatMemberStatus(parent)
{
    setType(CHAT_MEMBER_STATUS_BANNED);
}

QTdChatMemberStatusBanned::QTdChatMemberStatusBanned(QObject *parent, qint32 bannedUntilDate_)
    : QTdChatMemberStatus(parent),
    m_bannedUntilDate(bannedUntilDate_) {
    setType(CHAT_MEMBER_STATUS_BANNED);
}

qint32 QTdChatMemberStatusBanned::bannedUntilDate() const {
    return m_bannedUntilDate;
}

void QTdChatMemberStatusBanned::setBannedUntilDate(qint32 value) {
    if (m_bannedUntilDate != value) {
        m_bannedUntilDate = value;
        emit dataChanged();
    }
}

QJsonObject QTdChatMemberStatusBanned::marshalJson() {
    return QJsonObject{
        { "@type", QTdObject::typeString() },
        { "banned_until_date", m_bannedUntilDate }
    };
}

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

    QTdChatMemberStatus::unmarshalJson(json);
    m_bannedUntilDate = json["banned_until_date"].toInt();

    emit dataChanged();
}

QTdChatMemberStatus *QTdChatMemberStatusFactory::create(const QJsonObject &data, QObject *parent)
{
    QTdChatMemberStatus *result = Q_NULLPTR;
    const QString type = data["@type"].toString();
    if (type == "chatMemberStatusCreator") {
        result = new QTdChatMemberStatusCreator(parent);
    } else if (type == "chatMemberStatusAdministrator") {
        result = new QTdChatMemberStatusAdministrator(parent);
    } else if (type == "chatMemberStatusMember") {
        result = new QTdChatMemberStatusMember(parent);
    } else if (type == "chatMemberStatusRestricted") {
        result = new QTdChatMemberStatusRestricted(parent);
    } else if (type == "chatMemberStatusLeft") {
        result = new QTdChatMemberStatusLeft(parent);
    } else if (type == "chatMemberStatusBanned") {
        result = new QTdChatMemberStatusBanned(parent);
    }

    if (result) {
        result->unmarshalJson(data);
    }
    return result;
}