from ....tl.tlobject import TLObject
from ....utils import get_input_peer


class UploadMediaRequest(TLObject):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    messages.uploadMedia#519bc2b1 peer:InputPeer media:InputMedia = MessageMedia"""

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

    def __init__(self, peer, media):
        """
        :param peer: Telegram type: "InputPeer".
        :param media: Telegram type: "InputMedia".

        :returns MessageMedia: Instance of either MessageMediaEmpty, MessageMediaPhoto, MessageMediaGeo, MessageMediaContact, MessageMediaUnsupported, MessageMediaDocument, MessageMediaWebPage, MessageMediaVenue, MessageMediaGame, MessageMediaInvoice.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.peer = get_input_peer(peer)
        self.media = media

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

    def on_send(self, writer):
        writer.write_int(UploadMediaRequest.constructor_id, signed=False)
        self.peer.on_send(writer)
        self.media.on_send(writer)

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

    def on_response(self, reader):
        self.result = reader.tgread_object()

    def __repr__(self):
        return 'messages.uploadMedia#519bc2b1 peer:InputPeer media:InputMedia = MessageMedia'

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

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