MilanoteUnofficialApi.elements.link

 1from .element import Element
 2from .meta import Meta
 3from .location import Location
 4
 5
 6class Link(Element):
 7    """
 8    A Milanote link.
 9    """
10
11    id: str
12    """ID of the element."""
13    element_type: str
14    """Type of the element."""
15    meta: Meta
16    """Metadata of the element."""
17    location: Location
18    """Location of the element."""
19    url: str = None
20    """URL of the link."""
21    title: str = None
22    """Title of the link."""
23    link_type: str = None
24    """Type of the link."""
25
26    def __init__(self, data: dict):
27        super().__init__(data)
28        if "link" in data["content"]:
29            self.url = data["content"]["link"]["url"]
30            self.title = data["content"]["link"]["title"]
31        self.link_type = data["content"].get("linkType", None)
32
33    def __repr__(self):
34        return f"Link(id='{self.id}', title='{self.title}', link_type='{self.link_type}')"