from telethon.tl.mtproto_request import MTProtoRequest


class ImportContactsRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    contacts.importContacts#da30b32d contacts:Vector<InputContact> replace:Bool = contacts.ImportedContacts"""

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

    def __init__(self, contacts, replace):
        """
        :param contacts: Telegram type: «InputContact». Must be a list.
        :param replace: Telegram type: «Bool».
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.contacts = contacts
        self.replace = replace

    def on_send(self, writer):
        writer.write_int(ImportContactsRequest.constructor_id, signed=False)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.contacts))
        for contacts_item in self.contacts:
            contacts_item.on_send(writer)

        writer.tgwrite_bool(self.replace)

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

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

    def __repr__(self):
        return 'contacts.importContacts#da30b32d contacts:Vector<InputContact> replace:Bool = contacts.ImportedContacts'

    def __str__(self):
        return '(contacts.importContacts (ID: 0xda30b32d) = (contacts={}, replace={}))'.format(None if not self.contacts else [str(_) for _ in self.contacts], str(self.replace))
