from ...tl.tlobject import TLObject


class CdnFileHash(TLObject):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    cdnFileHash#77eec38f offset:int limit:int hash:bytes = CdnFileHash"""

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

    def __init__(self, offset, limit, hash):
        """
        :param offset: Telegram type: "int".
        :param limit: Telegram type: "int".
        :param hash: Telegram type: "bytes".

        Constructor for CdnFileHash: Instance of CdnFileHash.
        """
        super().__init__()

        self.offset = offset
        self.limit = limit
        self.hash = hash

    def to_dict(self):
        return {
            'offset': self.offset,
            'limit': self.limit,
            'hash': self.hash,
        }

    def on_send(self, writer):
        writer.write_int(CdnFileHash.constructor_id, signed=False)
        writer.write_int(self.offset)
        writer.write_int(self.limit)
        writer.tgwrite_bytes(self.hash)

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

    def on_response(self, reader):
        self.offset = reader.read_int()
        self.limit = reader.read_int()
        self.hash = reader.tgread_bytes()

    def __repr__(self):
        return 'cdnFileHash#77eec38f offset:int limit:int hash:bytes = CdnFileHash'

    def __str__(self):
        return TLObject.pretty_format(self)

    def stringify(self):
        return TLObject.pretty_format(self, indent=0)
