from ...tl.mtproto_request import MTProtoRequest


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

    # Telegram's constructor ID (and unique identifier) for this class
    constructor_id = 0x818426cd

    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 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 (all attributes are 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 '(peerSettings (ID: 0x818426cd) = (report_spam={}))'.format(str(self.report_spam))
