from ....tl.tlobject import TLObject


class GetWebPageRequest(TLObject):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    messages.getWebPage#32ca8f91 url:string hash:int = WebPage"""

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

    def __init__(self, url, hash):
        """
        :param url: Telegram type: "string".
        :param hash: Telegram type: "int".

        :returns WebPage: Instance of either WebPageEmpty, WebPagePending, WebPage, WebPageNotModified.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.url = url
        self.hash = hash

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

    def on_send(self, writer):
        writer.write_int(GetWebPageRequest.constructor_id, signed=False)
        writer.tgwrite_string(self.url)
        writer.write_int(self.hash)

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

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

    def __repr__(self):
        return 'messages.getWebPage#32ca8f91 url:string hash:int = WebPage'

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

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