from ....tl.mtproto_request import MTProtoRequest


class SetCallRatingRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    phone.setCallRating#1c536a34 peer:InputPhoneCall rating:int comment:string = Updates"""

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

    def __init__(self, peer, rating, comment):
        """
        :param peer: Telegram type: «InputPhoneCall».
        :param rating: Telegram type: «int».
        :param comment: Telegram type: «string».

        :returns Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, UpdatesTg, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.peer = peer
        self.rating = rating
        self.comment = comment

    def on_send(self, writer):
        writer.write_int(SetCallRatingRequest.constructor_id, signed=False)
        self.peer.on_send(writer)
        writer.write_int(self.rating)
        writer.tgwrite_string(self.comment)

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

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

    def __repr__(self):
        return 'phone.setCallRating#1c536a34 peer:InputPhoneCall rating:int comment:string = Updates'

    def __str__(self):
        return '(phone.setCallRating (ID: 0x1c536a34) = (peer={}, rating={}, comment={}))'.format(str(self.peer), str(self.rating), str(self.comment))
