from telethon.tl.mtproto_request import MTProtoRequest


class UpdateUserPhoto(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    updateUserPhoto#95313b0c user_id:int date:date photo:UserProfilePhoto previous:Bool = Update"""

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

    def __init__(self, user_id, date, photo, previous):
        """
        :param user_id: Telegram type: «int».
        :param date: Telegram type: «date».
        :param photo: Telegram type: «UserProfilePhoto».
        :param previous: Telegram type: «Bool».
        """
        super().__init__()

        self.user_id = user_id
        self.date = date
        self.photo = photo
        self.previous = previous

    def on_send(self, writer):
        writer.write_int(UpdateUserPhoto.constructor_id, signed=False)
        writer.write_int(self.user_id)
        writer.tgwrite_date(self.date)
        self.photo.on_send(writer)
        writer.tgwrite_bool(self.previous)

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

    def on_response(self, reader):
        self.user_id = reader.read_int()
        self.date = reader.tgread_date()
        self.photo = reader.tgread_object()
        self.previous = reader.tgread_bool()

    def __repr__(self):
        return 'updateUserPhoto#95313b0c user_id:int date:date photo:UserProfilePhoto previous:Bool = Update'

    def __str__(self):
        return '(updateUserPhoto (ID: 0x95313b0c) = (user_id={}, date={}, photo={}, previous={}))'.format(str(self.user_id), str(self.date), str(self.photo), str(self.previous))
