"""File generated by TLObjects' generator. All changes will be ERASED"""
from ...tl.tlobject import TLObject
from ...utils import get_input_channel


class GetChannelDifferenceRequest(TLObject):
    constructor_id = 0x3173d78
    subclass_of_id = 0x29896f5d

    def __init__(self, channel, filter, pts, limit, force=None):
        """
        :param force: Telegram type: "true".
        :param channel: Telegram type: "InputChannel".
        :param filter: Telegram type: "ChannelMessagesFilter".
        :param pts: Telegram type: "int".
        :param limit: Telegram type: "int".

        :returns updates.ChannelDifference: Instance of either ChannelDifferenceEmpty, ChannelDifferenceTooLong, ChannelDifference.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.force = force
        self.channel = get_input_channel(channel)
        self.filter = filter
        self.pts = pts
        self.limit = limit

    def to_dict(self):
        return {
            'force': self.force,
            'channel': None if self.channel is None else self.channel.to_dict(),
            'filter': None if self.filter is None else self.filter.to_dict(),
            'pts': self.pts,
            'limit': self.limit,
        }

    def on_send(self, writer):
        writer.write_int(GetChannelDifferenceRequest.constructor_id, signed=False)
        flags = 0
        flags |= (1 << 0) if self.force else 0
        writer.write_int(flags)

        self.channel.on_send(writer)
        self.filter.on_send(writer)
        writer.write_int(self.pts)
        writer.write_int(self.limit)

    @staticmethod
    def empty():
        return GetChannelDifferenceRequest(None, None, None, None, None)

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

    def __repr__(self):
        return 'updates.getChannelDifference#03173d78 flags:# force:flags.0?true channel:InputChannel filter:ChannelMessagesFilter pts:int limit:int = updates.ChannelDifference'

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

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



class GetDifferenceRequest(TLObject):
    constructor_id = 0x25939651
    subclass_of_id = 0x20482874

    def __init__(self, pts, date, qts, pts_total_limit=None):
        """
        :param pts: Telegram type: "int".
        :param pts_total_limit: Telegram type: "int".
        :param date: Telegram type: "date".
        :param qts: Telegram type: "int".

        :returns updates.Difference: Instance of either DifferenceEmpty, Difference, DifferenceSlice, DifferenceTooLong.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.pts = pts
        self.pts_total_limit = pts_total_limit
        self.date = date
        self.qts = qts

    def to_dict(self):
        return {
            'pts': self.pts,
            'pts_total_limit': self.pts_total_limit,
            'date': self.date,
            'qts': self.qts,
        }

    def on_send(self, writer):
        writer.write_int(GetDifferenceRequest.constructor_id, signed=False)
        flags = 0
        flags |= (1 << 0) if self.pts_total_limit else 0
        writer.write_int(flags)

        writer.write_int(self.pts)
        if self.pts_total_limit:
            writer.write_int(self.pts_total_limit)

        writer.tgwrite_date(self.date)
        writer.write_int(self.qts)

    @staticmethod
    def empty():
        return GetDifferenceRequest(None, None, None, None)

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

    def __repr__(self):
        return 'updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference'

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

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



class GetStateRequest(TLObject):
    constructor_id = 0xedd4882a
    subclass_of_id = 0x23df1a01

    def __init__(self):
        super().__init__()
        self.result = None
        self.content_related = True

    @staticmethod
    def to_dict():
        return {}

    def on_send(self, writer):
        writer.write_int(GetStateRequest.constructor_id, signed=False)

    @staticmethod
    def empty():
        return GetStateRequest()

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

    def __repr__(self):
        return 'updates.getState#edd4882a = updates.State'

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

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

