Skip to content

Content Management

Jean-Sébastien Sevestre edited this page Oct 29, 2019 · 18 revisions

Content listing

The lang parameter is mandatory for this call. You can add filters apidoc

contents = api.get_call("content", "list", body={"lang":"en"})

Content details

content = api.get_call("content", "get", uid="5386179638984704")

Content update

Get content with action=PAGE_EDIT to have all relevant data.

content = api.get_call("content", "get", uid="5386179638984704", action="PAGE_EDIT")

Note: the version number is used to lock ressource. You have to put the last version number of a content in version to be allowed to update a content, else a bad request:"CONTENT_NOT_UP_TO_DATE" will be returned.

Content creation

The simplest way to create content is to use an existing template. This template could carry all design configuration.

base_template = api.get_call("template", "get", uid="123456789")
# note : it's possible to use a content as well.

new_content = {"type": "page",
               "template": base_template[template],
               "customContentType": base_template["customContentType"],
               "customer": base_template["customer"],
               "instance": base_template["instance"],
               "feedKeys": base_template["feedKeys"],
               "publicationDate": base_template[publicationDate],
               "title": {"en": "created content from api"},
               "slug": {"en": "create-content-from-api"}, # WARNING : unique
               "metadata": [], # if any
           }

# customize content, widget, ...

new_content_saved = api.get_call("content","save",body=new_content)

Objects

Content

{
    "id" :"134567",
    "type":  "page",
    "status": "LIVE|ARCHIVED",
    "thumbnail" : "media library url",
    "publicationDate" : "2018-06-29T09:28:34.346124",
    "updatedAt": "2018-06-29T09:28:34.346124",
    "authorId": "23142536879786754" # set at creation time with the connected user
}

To create content on behalf other users you have to be connected with this user.

Content.template

The template property contains the whole page structure. Widgets are directly placed in this structure.

{ "template": {
    "components": [
        {
            "type": "row",
            "cells": [
            {
                "type": "cell",
                "components":[
                {
                    "type": "row|widget",
                    ...
                },
                ...]
            },
            ...]
        },
        ...]
    }
}

You should iterate over all the structure to find the correct widget to update.

Widget

Widget can be identified by their uuid

{
    "type": "widget",
    "widgetType": "contact|html|...",
    "uuid": "ca2bd99c-7b7e-11e8-8255-abba20e0e453",
}

Specific configuration goes in properties. Ex for an html widget:

{
    "type": "widget",
    "widgetType": "html",
    "uuid": "ca2bd99c-...",
    "properties": {
        "id": "identifier set in front > style > advance",
        "class": "class set in front > style > advance",
        "content":
            {
            "fr": "<p>Contenu html en francais</p>",
            "en": "<p>Html text in english </p>" },
    }
}

The properties>id (or class) could be used to simplify widget access from code and communication with design team.

## Global Widget

Global Widgets have one configuration that can be shared with many contents.

Global widgets have a dedicated api : ̀widget. with this api you can list, get and update global widgets.

global widget list

Api widget/list, provide instance id

response = api.get_call('widget', 'list', instance=INSTANCE_ID)

# example
[
    {
        "id": "6448894901878784",
        "uid": "6448894901878784",
        "instance": "5519565001981952",
        "customer": "4664706704080896",
        "widgetType": "html",
        "uuid": "7ea7407f-149e-489f-b00f-86f49512f555",
        "title": {
            "en": "Global Widget"
        },
        "properties": {
            "style": {
                "footer": {},
                "header": {}
            },
            "content": {
                "en": "<p>global html widget content</p>"
            },
            "popin": {
                "en": ""
            },
            "stylesMigrated": true,
            "global": {
                "isNew": true,
                "title": {
                    "en": "Global html widget"
                }
            }
        },
        "isMainWidget": false,
        "enabled": false,
        "isOverride": false,
        "isGlobal": true,
        "required": false,
        "status": "LIVE"
    }
]

global widget get

Api widget/get, provide widget uid

response = api.get_call('widget', 'get', uid="6448894901878784")

# example

{
    "id": "6448894901878784",
    "uid": "6448894901878784",
    "instance": "5519565001981952",
    "customer": "4664706704080896",
    "widgetType": "html",
    "uuid": "7ea7407f-149e-489f-b00f-86f49512f555",
    "title": {
        "en": "Global Widget"
    },
    "properties": {
        "style": {
            "footer": {},
            "header": {}
        },
        "content": {
            "en": "<p>global html widget content</p>"
        },
        "popin": {
            "en": ""
        },
        "stylesMigrated": true,
        "global": {
            "isNew": true,
            "title": {
                "en": "Global html widget"
            }
        }
    },
    "isMainWidget": false,
    "enabled": false,
    "isOverride": false,
    "isGlobal": true,
    "required": false,
    "status": "LIVE"
}

global widget save

Api widget/save, provide the widget object in the body

# First get the object
widget = api.get_call('widget', 'get', uid="6448894901878784")

# update some properties
widget['properties']['content']['en'] = "<p>updated content</p>"

# save
saved_widget = api.get_call('widget', 'save', body=widget)
Clone this wiki locally