from ....tl.mtproto_request import MTProtoRequest


class RegisterDeviceRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    account.registerDevice#637ea878 token_type:int token:string = Bool"""

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

    def __init__(self, token_type, token):
        """
        :param token_type: Telegram type: "int".
        :param token: Telegram type: "string".

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

        self.token_type = token_type
        self.token = token

    def to_dict(self):
        return {
            'token_type': self.token_type,
            'token': self.token,
        }

    def on_send(self, writer):
        writer.write_int(RegisterDeviceRequest.constructor_id, signed=False)
        writer.write_int(self.token_type)
        writer.tgwrite_string(self.token)

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

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

    def __repr__(self):
        return 'account.registerDevice#637ea878 token_type:int token:string = Bool'

    def __str__(self):
        return '(account.registerDevice (ID: 0x637ea878) = (token_type={}, token={}))'.format(str(self.token_type), str(self.token))
