from ...tl.mtproto_request import MTProtoRequest


class InputMessagesFilterPhoneCalls(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    inputMessagesFilterPhoneCalls#80c99768 flags:# missed:flags.0?true = MessagesFilter"""

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

    def __init__(self, missed=None):
        """
        :param missed: Telegram type: «true».

        Constructor for MessagesFilter: Instance of either InputMessagesFilterEmpty, InputMessagesFilterPhotos, InputMessagesFilterVideo, InputMessagesFilterPhotoVideo, InputMessagesFilterPhotoVideoDocuments, InputMessagesFilterDocument, InputMessagesFilterUrl, InputMessagesFilterGif, InputMessagesFilterVoice, InputMessagesFilterMusic, InputMessagesFilterChatPhotos, InputMessagesFilterPhoneCalls, InputMessagesFilterRoundVoice, InputMessagesFilterRoundVideo.
        """
        super().__init__()

        self.missed = missed

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


    @staticmethod
    def empty():
        """Returns an "empty" instance (all attributes are None)"""
        return InputMessagesFilterPhoneCalls(None)

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

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

    def __repr__(self):
        return 'inputMessagesFilterPhoneCalls#80c99768 flags:# missed:flags.0?true = MessagesFilter'

    def __str__(self):
        return '(inputMessagesFilterPhoneCalls (ID: 0x80c99768) = (missed={}))'.format(str(self.missed))
