from ....tl.mtproto_request import MTProtoRequest


class DeletePhotosRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    photos.deletePhotos#87cf7f2f id:Vector<InputPhoto> = Vector<long>"""

    # Telegram's constructor (U)ID for this class
    constructor_id = 0x87cf7f2f
    # Also the ID of its resulting type for fast checks
    subclass_of_id = 0x8918e168

    def __init__(self, id):
        """
        :param id: Telegram type: "InputPhoto". Must be a list.

        :returns Vector<long>: This type has no constructors.
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.id = id

    def to_dict(self):
        return {
            'id': [] if self.id is None else [None if x is None else x.to_dict() for x in self.id],
        }

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

    @staticmethod
    def empty():
        """Returns an "empty" instance (attributes=None)"""
        return DeletePhotosRequest(None)

    def on_response(self, reader):
        reader.read_int()  # Vector id
        count = reader.read_long()
        self.result = [reader.read_long() for _ in range(count)]

    def __repr__(self):
        return 'photos.deletePhotos#87cf7f2f id:Vector<InputPhoto> = Vector<long>'

    def __str__(self):
        return '(photos.deletePhotos (ID: 0x87cf7f2f) = (id={}))'.format(None if not self.id else [str(_) for _ in self.id])
