"""File auto-generated by tglib TL generator. Do not edit manually."""
from ..tlobject import TLObject
from ..tlobject import TLRequest
from typing import Optional, List, Union
import os
import struct
from datetime import datetime


class DeleteFolderRequest(TLRequest):
    """TL type: folders.deleteFolder"""
    CONSTRUCTOR_ID = 0x1c295881
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, folder_id: int):
        self.folder_id = folder_id

    def to_dict(self):
        return {
            '_': 'DeleteFolderRequest',
            'folder_id': self.folder_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.folder_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_folder_id = reader.read_int()
        _args['folder_id'] = _val_folder_id
        return cls(**_args)


class EditPeerFoldersRequest(TLRequest):
    """TL type: folders.editPeerFolders"""
    CONSTRUCTOR_ID = 0x6847d0ab
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, folder_peers: List['TypeInputFolderPeer']):
        self.folder_peers = folder_peers

    def to_dict(self):
        return {
            '_': 'EditPeerFoldersRequest',
            'folder_peers': self.folder_peers,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.folder_peers)))
        for item in self.folder_peers:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_folder_peers = reader.read_int()
        _list_folder_peers = []
        for _ in range(_count_folder_peers):
            _item_folder_peers = reader.tgread_object()
            _list_folder_peers.append(_item_folder_peers)
        _args['folder_peers'] = _list_folder_peers
        return cls(**_args)

