from ....tl.tlobject import TLObject
from ....utils import get_input_channel


class ReadHistoryRequest(TLObject):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    channels.readHistory#cc104937 channel:InputChannel max_id:int = Bool"""

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

    def __init__(self, channel, max_id):
        """
        :param channel: Telegram type: "InputChannel".
        :param max_id: Telegram type: "int".

        :returns Bool: This type has no constructors.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = get_input_channel(channel)
        self.max_id = max_id

    def to_dict(self):
        return {
            'channel': None if self.channel is None else self.channel.to_dict(),
            'max_id': self.max_id,
        }

    def on_send(self, writer):
        writer.write_int(ReadHistoryRequest.constructor_id, signed=False)
        self.channel.on_send(writer)
        writer.write_int(self.max_id)

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

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

    def __repr__(self):
        return 'channels.readHistory#cc104937 channel:InputChannel max_id:int = Bool'

    def __str__(self):
        return TLObject.pretty_format(self)

    def stringify(self):
        return TLObject.pretty_format(self, indent=0)
