from telethon.tl.mtproto_request import MTProtoRequest


class InitConnectionRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    initConnection#69796de9 {X:Type} api_id:int device_model:string system_version:string app_version:string lang_code:string query:!X = X"""

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

    def __init__(self, api_id, device_model, system_version, app_version, lang_code, query):
        """
        :param api_id: Telegram type: «int».
        :param device_model: Telegram type: «string».
        :param system_version: Telegram type: «string».
        :param app_version: Telegram type: «string».
        :param lang_code: Telegram type: «string».
        :param query: Telegram type: «X». This should be another MTProtoRequest.
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.api_id = api_id
        self.device_model = device_model
        self.system_version = system_version
        self.app_version = app_version
        self.lang_code = lang_code
        self.query = query

    def on_send(self, writer):
        writer.write_int(InitConnectionRequest.constructor_id, signed=False)
        writer.write_int(self.api_id)
        writer.tgwrite_string(self.device_model)
        writer.tgwrite_string(self.system_version)
        writer.tgwrite_string(self.app_version)
        writer.tgwrite_string(self.lang_code)
        self.query.on_send(writer)

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

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

    def __repr__(self):
        return 'initConnection#69796de9 {X:Type} api_id:int device_model:string system_version:string app_version:string lang_code:string query:!X = X'

    def __str__(self):
        return '(initConnection (ID: 0x69796de9) = (api_id={}, device_model={}, system_version={}, app_version={}, lang_code={}, query={}))'.format(str(self.api_id), str(self.device_model), str(self.system_version), str(self.app_version), str(self.lang_code), str(self.query))
