from ....tl.mtproto_request import MTProtoRequest
from ....utils import get_input_peer


class SetTypingRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    messages.setTyping#a3825e50 peer:InputPeer action:SendMessageAction = Bool"""

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

    def __init__(self, peer, action):
        """
        :param peer: Telegram type: "InputPeer".
        :param action: Telegram type: "SendMessageAction".

        :returns Bool: This type has no constructors.
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.peer = get_input_peer(peer)
        self.action = action

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

    def on_send(self, writer):
        writer.write_int(SetTypingRequest.constructor_id, signed=False)
        self.peer.on_send(writer)
        self.action.on_send(writer)

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

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

    def __repr__(self):
        return 'messages.setTyping#a3825e50 peer:InputPeer action:SendMessageAction = Bool'

    def __str__(self):
        return '(messages.setTyping (ID: 0xa3825e50) = (peer={}, action={}))'.format(str(self.peer), str(self.action))
