from ....tl.tlobject import TLObject


class SentEncryptedFile(TLObject):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    messages.sentEncryptedFile#9493ff32 date:int file:EncryptedFile = messages.SentEncryptedMessage"""

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

    def __init__(self, date, file):
        """
        :param date: Telegram type: "date".
        :param file: Telegram type: "EncryptedFile".

        Constructor for messages.SentEncryptedMessage: Instance of either SentEncryptedMessage, SentEncryptedFile.
        """
        super().__init__()

        self.date = date
        self.file = file

    def to_dict(self):
        return {
            'date': self.date,
            'file': None if self.file is None else self.file.to_dict(),
        }

    def on_send(self, writer):
        writer.write_int(SentEncryptedFile.constructor_id, signed=False)
        writer.tgwrite_date(self.date)
        self.file.on_send(writer)

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

    def on_response(self, reader):
        self.date = reader.tgread_date()
        self.file = reader.tgread_object()

    def __repr__(self):
        return 'messages.sentEncryptedFile#9493ff32 date:int file:EncryptedFile = messages.SentEncryptedMessage'

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

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