from ...tl.tlobject import TLObject


class PeerSettings(TLObject):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    peerSettings#818426cd flags:# report_spam:flags.0?true = PeerSettings"""

    # Telegram's constructor (U)ID for this class
    constructor_id = 0x818426cd
    # Also the ID of its resulting type for fast checks
    subclass_of_id = 0xf6a79f84

    def __init__(self, report_spam=None):
        """
        :param report_spam: Telegram type: "true".

        Constructor for PeerSettings: Instance of PeerSettings.
        """
        super().__init__()

        self.report_spam = report_spam

    def to_dict(self):
        return {
            'report_spam': self.report_spam,
        }

    def on_send(self, writer):
        writer.write_int(PeerSettings.constructor_id, signed=False)
        # Calculate the flags. This equals to those flag arguments which are NOT None
        flags = 0
        flags |= (1 << 0) if self.report_spam else 0
        writer.write_int(flags)


    @staticmethod
    def empty():
        """Returns an "empty" instance (attributes=None)"""
        return PeerSettings(None)

    def on_response(self, reader):
        flags = reader.read_int()

        if (flags & (1 << 0)) != 0:
            self.report_spam = True  # Arbitrary not-None value, no need to read since it is a flag

    def __repr__(self):
        return 'peerSettings#818426cd flags:# report_spam:flags.0?true = PeerSettings'

    def __str__(self):
        return TLObject.pretty_format(self)

    def stringify(self):
        return TLObject.pretty_format(self, indent=0)
