Source code for

from dataclasses import dataclass
from typing import TYPE_CHECKING

from ._utils import AttrDict

    from .account import Account
    from .chat import Chat
    from .rpc import Rpc

[docs] @dataclass class Contact: """ Contact API. Essentially a wrapper for RPC, account ID and a contact ID. """ account: "Account" id: int @property def _rpc(self) -> "Rpc": return self.account._rpc
[docs] def block(self) -> None: """Block contact.""" self._rpc.block_contact(,
[docs] def unblock(self) -> None: """Unblock contact.""" self._rpc.unblock_contact(,
[docs] def delete(self) -> None: """Delete contact.""" self._rpc.delete_contact(,
[docs] def set_name(self, name: str) -> None: """Change the name of this contact.""" self._rpc.change_contact_name(,, name)
[docs] def get_encryption_info(self) -> str: """Get a multi-line encryption info, containing your fingerprint and the fingerprint of the contact. """ return self._rpc.get_contact_encryption_info(,
[docs] def get_snapshot(self) -> AttrDict: """Return a dictionary with a snapshot of all contact properties.""" snapshot = AttrDict(self._rpc.get_contact(, snapshot["contact"] = self return snapshot
[docs] def create_chat(self) -> "Chat": """Create or get an existing 1:1 chat for this contact.""" from .chat import Chat return Chat( self.account, self._rpc.create_chat_by_contact_id(,, )
def make_vcard(self) -> str: return self._rpc.make_vcard(, [])