from ...tl.tlobject import TLObject


class FoundGifCached(TLObject):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    foundGifCached#9c750409 url:string photo:Photo document:Document = FoundGif"""

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

    def __init__(self, url, photo, document):
        """
        :param url: Telegram type: "string".
        :param photo: Telegram type: "Photo".
        :param document: Telegram type: "Document".

        Constructor for FoundGif: Instance of either FoundGif, FoundGifCached.
        """
        super().__init__()

        self.url = url
        self.photo = photo
        self.document = document

    def to_dict(self):
        return {
            'url': self.url,
            'photo': None if self.photo is None else self.photo.to_dict(),
            'document': None if self.document is None else self.document.to_dict(),
        }

    def on_send(self, writer):
        writer.write_int(FoundGifCached.constructor_id, signed=False)
        writer.tgwrite_string(self.url)
        self.photo.on_send(writer)
        self.document.on_send(writer)

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

    def on_response(self, reader):
        self.url = reader.tgread_string()
        self.photo = reader.tgread_object()
        self.document = reader.tgread_object()

    def __repr__(self):
        return 'foundGifCached#9c750409 url:string photo:Photo document:Document = FoundGif'

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

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