from ....tl.mtproto_request import MTProtoRequest


class RequestEncryptionRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    messages.requestEncryption#f64daf43 user_id:InputUser random_id:int g_a:bytes = EncryptedChat"""

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

    def __init__(self, user_id, random_id, g_a):
        """
        :param user_id: Telegram type: «InputUser».
        :param random_id: Telegram type: «int».
        :param g_a: Telegram type: «bytes».

        :returns EncryptedChat: Instance of either EncryptedChatEmpty, EncryptedChatWaiting, EncryptedChatRequested, EncryptedChat, EncryptedChatDiscarded.
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.user_id = user_id
        self.random_id = random_id
        self.g_a = g_a

    def on_send(self, writer):
        writer.write_int(RequestEncryptionRequest.constructor_id, signed=False)
        self.user_id.on_send(writer)
        writer.write_int(self.random_id)
        writer.tgwrite_bytes(self.g_a)

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

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

    def __repr__(self):
        return 'messages.requestEncryption#f64daf43 user_id:InputUser random_id:int g_a:bytes = EncryptedChat'

    def __str__(self):
        return '(messages.requestEncryption (ID: 0xf64daf43) = (user_id={}, random_id={}, g_a={}))'.format(str(self.user_id), str(self.random_id), str(self.g_a))
