from telethon.tl.mtproto_request import MTProtoRequest


class UpdateNewAuthorization(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    updateNewAuthorization#8f06529a auth_key_id:long date:date device:string location:string = Update"""

    # Telegram's constructor ID (and unique identifier) for this class
    constructor_id = 0x8f06529a

    def __init__(self, auth_key_id, date, device, location):
        """
        :param auth_key_id: Telegram type: «long».
        :param date: Telegram type: «date».
        :param device: Telegram type: «string».
        :param location: Telegram type: «string».
        """
        super().__init__()

        self.auth_key_id = auth_key_id
        self.date = date
        self.device = device
        self.location = location

    def on_send(self, writer):
        writer.write_int(UpdateNewAuthorization.constructor_id, signed=False)
        writer.write_long(self.auth_key_id)
        writer.tgwrite_date(self.date)
        writer.tgwrite_string(self.device)
        writer.tgwrite_string(self.location)

    @staticmethod
    def empty():
        """Returns an "empty" instance (all attributes are None)"""
        return UpdateNewAuthorization(None, None, None, None)

    def on_response(self, reader):
        self.auth_key_id = reader.read_long()
        self.date = reader.tgread_date()
        self.device = reader.tgread_string()
        self.location = reader.tgread_string()

    def __repr__(self):
        return 'updateNewAuthorization#8f06529a auth_key_id:long date:date device:string location:string = Update'

    def __str__(self):
        return '(updateNewAuthorization (ID: 0x8f06529a) = (auth_key_id={}, date={}, device={}, location={}))'.format(str(self.auth_key_id), str(self.date), str(self.device), str(self.location))
