from telethon.tl.mtproto_request import MTProtoRequest


class UpdateDcOptions(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    updateDcOptions#8e5e9873 dc_options:Vector<DcOption> = Update"""

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

    def __init__(self, dc_options):
        """
        :param dc_options: Telegram type: «DcOption». Must be a list.
        """
        super().__init__()

        self.dc_options = dc_options

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

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

    def on_response(self, reader):
        reader.read_int()  # Vector's constructor ID
        self.dc_options = []  # Initialize an empty list
        dc_options_len = reader.read_int()
        for _ in range(dc_options_len):
            dc_options_item = reader.tgread_object()
            self.dc_options.append(dc_options_item)

    def __repr__(self):
        return 'updateDcOptions#8e5e9873 dc_options:Vector<DcOption> = Update'

    def __str__(self):
        return '(updateDcOptions (ID: 0x8e5e9873) = (dc_options={}))'.format(None if not self.dc_options else [str(_) for _ in self.dc_options])
