"""File generated by TLObjects' generator. All changes will be ERASED"""
from ...tl.tlobject import TLObject
from typing import Optional, List, Union, TYPE_CHECKING
import os
import struct
if TYPE_CHECKING:
    from ...tl.types import TypeInputChannel, TypeChannelMessagesFilter



class GetChannelDifferenceRequest(TLObject):
    CONSTRUCTOR_ID = 0x3173d78
    SUBCLASS_OF_ID = 0x29896f5d

    def __init__(self, channel, filter, pts, limit, force=None):
        """
        :param TypeInputChannel channel:
        :param TypeChannelMessagesFilter filter:
        :param int pts:
        :param int limit:
        :param Optional[bool] force:

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

        self.channel = channel  # type: TypeInputChannel
        self.filter = filter  # type: TypeChannelMessagesFilter
        self.pts = pts  # type: int
        self.limit = limit  # type: int
        self.force = force  # type: Optional[bool]

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

    def to_dict(self):
        return {
            '_': 'GetChannelDifferenceRequest',
            '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,
            'force': self.force
        }

    def __bytes__(self):
        return b''.join((
            b'x=\x17\x03',
            struct.pack('<I', (0 if self.force is None or self.force is False else 1)),
            bytes(self.channel),
            bytes(self.filter),
            struct.pack('<i', self.pts),
            struct.pack('<i', self.limit),
        ))

    @classmethod
    def from_reader(cls, reader):
        flags = reader.read_int()

        _force = bool(flags & 1)
        _channel = reader.tgread_object()
        _filter = reader.tgread_object()
        _pts = reader.read_int()
        _limit = reader.read_int()
        return cls(channel=_channel, filter=_filter, pts=_pts, limit=_limit, force=_force)


class GetDifferenceRequest(TLObject):
    CONSTRUCTOR_ID = 0x25939651
    SUBCLASS_OF_ID = 0x20482874

    def __init__(self, pts, date, qts, pts_total_limit=None):
        """
        :param int pts:
        :param Optional[datetime] date:
        :param int qts:
        :param Optional[int] pts_total_limit:

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

        self.pts = pts  # type: int
        self.date = date  # type: Optional[datetime]
        self.qts = qts  # type: int
        self.pts_total_limit = pts_total_limit  # type: Optional[int]

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

    def __bytes__(self):
        return b''.join((
            b'Q\x96\x93%',
            struct.pack('<I', (0 if self.pts_total_limit is None or self.pts_total_limit is False else 1)),
            struct.pack('<i', self.pts),
            b'' if self.pts_total_limit is None or self.pts_total_limit is False else (struct.pack('<i', self.pts_total_limit)),
            TLObject.serialize_datetime(self.date),
            struct.pack('<i', self.qts),
        ))

    @classmethod
    def from_reader(cls, reader):
        flags = reader.read_int()

        _pts = reader.read_int()
        if flags & 1:
            _pts_total_limit = reader.read_int()
        else:
            _pts_total_limit = None
        _date = reader.tgread_date()
        _qts = reader.read_int()
        return cls(pts=_pts, date=_date, qts=_qts, pts_total_limit=_pts_total_limit)


class GetStateRequest(TLObject):
    CONSTRUCTOR_ID = 0xedd4882a
    SUBCLASS_OF_ID = 0x23df1a01

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

    def to_dict(self):
        return {
            '_': 'GetStateRequest'
        }

    def __bytes__(self):
        return b''.join((
            b'*\x88\xd4\xed',
        ))

    @classmethod
    def from_reader(cls, reader):
        return cls()

