from ...tl.mtproto_request import MTProtoRequest


class TopPeer(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    topPeer#edcdc05b peer:Peer rating:double = TopPeer"""

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

    def __init__(self, peer, rating):
        """
        :param peer: Telegram type: «Peer».
        :param rating: Telegram type: «double».

        Constructor for TopPeer: Instance of TopPeer.
        """
        super().__init__()

        self.peer = peer
        self.rating = rating

    def on_send(self, writer):
        writer.write_int(TopPeer.constructor_id, signed=False)
        self.peer.on_send(writer)
        writer.write_double(self.rating)

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

    def on_response(self, reader):
        self.peer = reader.tgread_object()
        self.rating = reader.read_double()

    def __repr__(self):
        return 'topPeer#edcdc05b peer:Peer rating:double = TopPeer'

    def __str__(self):
        return '(topPeer (ID: 0xedcdc05b) = (peer={}, rating={}))'.format(str(self.peer), str(self.rating))
