from telethon.tl.mtproto_request import MTProtoRequest


class PhotoSize(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = PhotoSize"""

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

    def __init__(self, type, location, w, h, size):
        """
        :param type: Telegram type: «string».
        :param location: Telegram type: «FileLocation».
        :param w: Telegram type: «int».
        :param h: Telegram type: «int».
        :param size: Telegram type: «int».
        """
        super().__init__()

        self.type = type
        self.location = location
        self.w = w
        self.h = h
        self.size = size

    def on_send(self, writer):
        writer.write_int(PhotoSize.constructor_id, signed=False)
        writer.tgwrite_string(self.type)
        self.location.on_send(writer)
        writer.write_int(self.w)
        writer.write_int(self.h)
        writer.write_int(self.size)

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

    def on_response(self, reader):
        self.type = reader.tgread_string()
        self.location = reader.tgread_object()
        self.w = reader.read_int()
        self.h = reader.read_int()
        self.size = reader.read_int()

    def __repr__(self):
        return 'photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = PhotoSize'

    def __str__(self):
        return '(photoSize (ID: 0x77bfb61b) = (type={}, location={}, w={}, h={}, size={}))'.format(str(self.type), str(self.location), str(self.w), str(self.h), str(self.size))
