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


class GetParticipantRequest(TLObject):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    channels.getParticipant#546dd7a6 channel:InputChannel user_id:InputUser = channels.ChannelParticipant"""

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

    def __init__(self, channel, user_id):
        """
        :param channel: Telegram type: "InputChannel".
        :param user_id: Telegram type: "InputUser".

        :returns channels.ChannelParticipant: Instance of ChannelParticipant.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = get_input_channel(channel)
        self.user_id = get_input_user(user_id)

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

    def on_send(self, writer):
        writer.write_int(GetParticipantRequest.constructor_id, signed=False)
        self.channel.on_send(writer)
        self.user_id.on_send(writer)

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

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

    def __repr__(self):
        return 'channels.getParticipant#546dd7a6 channel:InputChannel user_id:InputUser = channels.ChannelParticipant'

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

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