How to use the gkeepapi.node.WebLink function in gkeepapi

To help you get started, we’ve selected a few gkeepapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kiwiz / gkeepapi / test / test_nodes.py View on Github external
def test_weblink_fields(self):
        n = node.WebLink()

        TITLE = 'Title'
        URL = 'https://url.url'
        IMAGEURL = 'https://img.url'
        PROVENANCEURL = 'https://provenance.url'
        DESCRIPTION = 'Description'

        clean_node(n)
        n.title = TITLE
        self.assertTrue(n.dirty)
        self.assertEqual(TITLE, n.title)

        clean_node(n)
        n.url = URL
        self.assertTrue(n.dirty)
        self.assertEqual(URL, n.url)
github kiwiz / gkeepapi / test / test_nodes.py View on Github external
n.append(sub)
        self.assertTrue(n.dirty)
        self.assertEqual(CATEGORY, n.category)

        clean_node(n)
        sub.category = CATEGORY_2
        self.assertTrue(n.dirty)
        self.assertEqual(CATEGORY_2, n.category)

        clean_node(n)
        n.remove(sub)
        self.assertTrue(n.dirty)

        self.assertEqual([], n.links)

        sub = node.WebLink()
        clean_node(sub)

        clean_node(n)
        n.append(sub)
        self.assertTrue(n.dirty)
        self.assertEqual([sub], n.links)
github kiwiz / gkeepapi / test / test_nodes.py View on Github external
def test_save_load(self):
        a, b = generate_save_load(node.Annotation)
        self.assertEqual(a, b)

        # Test WebLink
        a, b = generate_save_load(node.WebLink)
        self.assertEqual(a, b)

        # Test Category
        def Category():
            c = node.Category()
            c.category = node.CategoryValue.Books
            return c
        a, b = generate_save_load(Category)
        self.assertEqual(a, b)
github kiwiz / gkeepapi / test / test_nodes.py View on Github external
def test_subannotations(self):
        n = node.Context()
        sub = node.WebLink()
        sub.id = None

        n._entries['x'] = sub

        data = n.save()

        n.load(data)
        self.assertEqual(1, len(n._entries))
github kiwiz / gkeepapi / gkeepapi / node.py View on Github external
def from_json(cls, raw):
        """Helper to construct an annotation from a dict.

        Args:
            raw (dict): Raw annotation representation.

        Returns:
            Node: An Annotation object or None.
        """
        bcls = None
        if 'webLink' in raw:
            bcls = WebLink
        elif 'topicCategory' in raw:
            bcls = Category
        elif 'taskAssist' in raw:
            bcls = TaskAssist
        elif 'context' in raw:
            bcls = Context

        if bcls is None:
            logger.warning('Unknown annotation type: %s', raw.keys())
            return None
        annotation = bcls()
        annotation.load(raw)

        return annotation
github kiwiz / gkeepapi / gkeepapi / node.py View on Github external
def links(self):
        """Get all links.

        Returns:
            list[gkeepapi.node.WebLink]: A list of links.
        """
        return [annotation for annotation in self._annotations.values()
            if isinstance(annotation, WebLink)
        ]
github kiwiz / gkeepapi / gkeepapi / node.py View on Github external
def save(self, clean=True):
        ret = super(WebLink, self).save(clean)
        ret['webLink'] = {
            'title': self._title,
            'url': self._url,
            'imageUrl': self._image_url,
            'provenanceUrl': self._provenance_url,
            'description': self._description,
        }
        return ret