from ...tl.mtproto_request import MTProtoRequest


class InputMediaDocumentExternal(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    inputMediaDocumentExternal#e5e9607c url:string caption:string = InputMedia"""

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

    def __init__(self, url, caption):
        """
        :param url: Telegram type: «string».
        :param caption: Telegram type: «string».

        Constructor for InputMedia: Instance of either InputMediaEmpty, InputMediaUploadedPhoto, InputMediaPhoto, InputMediaGeoPoint, InputMediaContact, InputMediaUploadedDocument, InputMediaUploadedThumbDocument, InputMediaDocument, InputMediaVenue, InputMediaGifExternal, InputMediaPhotoExternal, InputMediaDocumentExternal, InputMediaGame, InputMediaInvoice.
        """
        super().__init__()

        self.url = url
        self.caption = caption

    def on_send(self, writer):
        writer.write_int(InputMediaDocumentExternal.constructor_id, signed=False)
        writer.tgwrite_string(self.url)
        writer.tgwrite_string(self.caption)

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

    def on_response(self, reader):
        self.url = reader.tgread_string()
        self.caption = reader.tgread_string()

    def __repr__(self):
        return 'inputMediaDocumentExternal#e5e9607c url:string caption:string = InputMedia'

    def __str__(self):
        return '(inputMediaDocumentExternal (ID: 0xe5e9607c) = (url={}, caption={}))'.format(str(self.url), str(self.caption))
