{
"info": {
"author": "Leukeleu",
"author_email": "info@leukeleu.nl",
"bugtrack_url": null,
"classifiers": [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5"
],
"description": "#############################\nStichting Opvoeden API client\n#############################\n\nA client for the `stichtingopvoeden.nl`_ `API version 2`_.\n\n\nUsage\n=====\n\nImport the client class from ``opvoeden_api.client`` and instantiate\nit with an API key::\n\n client = Client(MY_API_KEY)\n\nThe client methods map to the following set of endpoints:\n\n=============================== =======================================\nMethod Endpoint\n=============================== =======================================\n``contentset_list`` `/rest/v2/contentset`_\n``contentset(contentset_id)`` `/rest/v2/contentset/{id}`_\n``article(external_reference)`` `/rest/v2/article/{externalReference}`_\n``image(image_id)`` `/rest/v2/image/{id}`_\n=============================== =======================================\n\n.. note:: The ``contentset`` method does not support the ``changedAfter``\n or ``article`` parameters that are documented in the API docs.\n\n\nData types\n==========\n\nEach client method returns a different data type.\n\n\n``ContentSet``\n--------------\n\nThe ``contentset_list`` method returns a ``list`` of\n``ContentSet`` objects.\n\nA ``ContentSet`` object has of the following properties:\n\n* ``contentset_id``\n* ``name``\n* ``description``\n* ``is_default``\n\nRefer to the `API data types docs`_ for more information on\nthese fields.\n\n\n``ArticleNode``\n---------------\n\nThe ``contentset(contentset_id)`` method returns a single ``ArticleNode``.\nThis node represents the root of a tree of ``Articles``.\n\nAn ``ArticleNode`` has the following properties:\n\n``article``\n The ``Article`` instance associated with this node\n``children``\n A ``list`` of ``ArticleNode`` instances of which the current node\n is the parent.\n\nIt is possible to iterate over an article node. This will traverse the\nentire tree in a depth first order. So, for example, to get a flat list\nof all the articles in a tree one could do this::\n\n tree = client.contentset(1)\n articles = [node.article for node in tree if node.article]\n\n\nTo recurse over the tree use the children property::\n\n def visit(node, parent=None):\n \"\"\"\n Visit each node in the tree.\n \"\"\"\n # do something with node, then recurse\n for child in node.children:\n visit(child, node)\n\n tree = client.contentset(1)\n visit(tree)\n\n\n``Article``\n-----------\n\nThe ``article(external_reference)`` method returns a single ``Article``\ninstance. Another way to get an ``Article`` object is by accessing\nthe ``article`` property of an ``ArticleNode``.\n\nAn ``Article`` has the following properties:\n\n* ``external_reference``\n* ``short_title``\n* ``title``\n* ``article_text``\n* ``parent_reference``\n* ``position``\n* ``last_change_date``\n* ``canonicaltag``\n* ``tags``\n\nRefer to the `API data types docs`_ for more information on\nthese fields.\n\n.. note:: The ``article_text`` of ``Articles`` retrieved from the\n ``contentset`` endpoint can contain several placeholder strings.\n This library provides a number of `utilities`__\n to deal with those.\n\nIn addition to these fields the ``Article`` object also\nprovides these properties:\n\n``path``\n The url of the article. This is identical to the ``canonicaltag``\n but the ``schema://domain`` prefix is stripped.\n``slug``\n The last element of the path. i.e. if ``path`` is ``'/foo/bar/'``\n then ``slug`` will be ``'bar'``.\n\n``Image``\n---------\n\nThe ``image(image_id)`` method returns a single ``Image``\ninstance.\n\n* ``image_id``\n* ``data``\n* ``content_type``\n* ``name``\n* ``creation_date``\n\nRefer to the `API data types docs`_ for more information on\nthese fields.\n\nConverting image data to binary\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe ``Image`` object also provides an ``as_binary`` method.\n\nThis method converts to base64 encoded value of the ``data``\nproperty to binary. The return value of this method can be used\nto store images on a file system.\n\n__\n\nArticle utils\n=============\n\nThe ``article_text`` of ``Articles`` returned by the ``contentset``\nmethod can contain a number special placeholder strings.\n\n``opvoeden_api.article_utils`` provides functions to deal with\nthese placeholders.\n\n\nReplace JGZ placeholders\n------------------------\n\nTo replace `JGZ placeholders`_ with appropriate strings use\n``replace_jgz``.\n\nBy default these are the substitutions:\n\n=========== =====================================\nPlaceholder Substitution\n=========== =====================================\njgz centrum voor Jeugd en Gezin (CJG)\nJgz Centrum voor Jeugd en Gezin (CJG)\njgzs CJG\u2019s\nJgzs CJG\u2019s\nde jgzs de CJG\u2019s\nDe jgzs De CJG\u2019s\nhet jgz het Centrum voor Jeugd en Gezin (CJG)\nHet jgz Het Centrum voor Jeugd en Gezin (CJG)\n=========== =====================================\n\nTo override any of the substitutions use the optional\n``substitutions`` argument to ``replace_jgz`` i.e.::\n\n replace_jgz(article_text, substitutions={\n 'jgz': 'centrum voor Jeugd en Gezin'\n })\n\n\nReplace internal link placeholders\n----------------------------------\n\nTo replace `internal link placeholders`_ use ``replace_links``\nwith a replacement callback.\n\nThe replacement callback is called with the ``external_id``\nand ``link_text`` for each placeholder in the article text.\n\nIf the replacement callback returns anything other than ``None``\nthe link is replaced with the return value.\n\nFor example::\n\n external_id_to_href = {\n '1': '/example/',\n '2': '/example/more/'\n }\n\n def get_link(external_id, link_text):\n \"\"\"\n Get the url for an article and return an HTML snippet\n that links to this url with the given text.\n\n \"\"\"\n href = external_id_to_href.get(external_id, None)\n if href:\n return '{}'.format(href, link_text)\n\n replace_links(article_text, get_link)\n\n\nReplace image placeholders\n--------------------------\n\nTo replace `image placeholders`_ use ``replace_images``\nwith a replacement callback.\n\nThe replacement callback is called with the ``image_id``\nfor each placeholder in the article text.\n\nIf the replacement callback returns anything other than ``None``\nthe placeholder is replaced with the return value.\n\nFor example::\n\n image_id_to_src = {\n '1': '/media/1.gif',\n '2': '/media/2.gif'\n }\n\n def get_image_tag(image_id):\n src = image_id_to_src.get(image_id, None)\n if src:\n return '
'.format(src)\n\n\n.. hint:: The replacement callback is an excellent place call the\n image endpoint of the API.\n\n\nReplace video placeholders\n--------------------------\n\nTo replace `YouTube video placeholders`_ use ``replace_videos``\nwith a replacement callback.\n\nThe replacement callback is called with the ``video_id``, ``embed_url``\nand ``external_url`` for each placeholder in the article text.\n\nIf the replacement callback returns anything other than ``None``\nthe placeholder is replaced with the return value.\n\nSome examples::\n\n def get_video_embed(video_id, embed_url, external_url):\n \"\"\"Create an iframe to embed the video\"\"\"\n return '