from ....tl.mtproto_request import MTProtoRequest


class GetPrivacyRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    account.getPrivacy#dadbc950 key:InputPrivacyKey = account.PrivacyRules"""

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

    def __init__(self, key):
        """
        :param key: Telegram type: "InputPrivacyKey".

        :returns account.PrivacyRules: Instance of PrivacyRules.
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.key = key

    def to_dict(self):
        return {
            'key': None if self.key is None else self.key.to_dict(),
        }

    def on_send(self, writer):
        writer.write_int(GetPrivacyRequest.constructor_id, signed=False)
        self.key.on_send(writer)

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

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

    def __repr__(self):
        return 'account.getPrivacy#dadbc950 key:InputPrivacyKey = account.PrivacyRules'

    def __str__(self):
        return '(account.getPrivacy (ID: 0xdadbc950) = (key={}))'.format(str(self.key))
