Purposes & preferences

This section relates to Preferences widgets only.

A widget is built with entities.

You can choose a widget type when creating a widget, allowing you to select one or all selected purposes and preferences from the Configuration Tree. For every element selected including its children (purpose, preference and preference value), an entity is created.

They are needed for either enabling / disabling or reordering certains part of the tree within a widget.

Get a list of entities

To retrieve a list of entities, send a GET request on /widgets/preferences-centers/layout-entities.

To retrieve an entity of a specific widget, add widget_id query to following GET request with id of your widget.

GET https://api.didomi.io/widgets/preferences-centers/layout-entities?organization_id=YOUR_ORG_ID&widget_id=YOUR_WIDGET_ID

[
    {
        "id": "String",
        "created_at": "Date",
        "updated_at": "Date",
        "parent_id": null,
        "selected_purpose_id": "String" || null,
        "selected_preference_id": "String" || null,
        "preference_value_id": "String" || null,
        "layout_component_id": "String",
        "enabled": false,
        "organization_id": "String",
        "widget_id": "String",
        "order": 0
    }
]

Hide / Display an entity

To hide or display an entity, send a PATCH request on /widgets/preferences-centers/layout-entities/{id}.

PATCH https://api.didomi.io/widgets/preferences-centers/layout-entities/{id}?organization_id=YOUR_ORG_ID

{
    /**
    * true: entity is displayed
    * false: entity is hidden
    */
    "enabled": true || false
}

Hide / Display multiple entities

To hide or display multiple entities, send a PATCH request on /widgets/preferences-centers/layout-entities.

PATCH https://api.didomi.io/widgets/preferences-centers/layout-entities?organization_id=YOUR_ORG_ID
[
    {
        "id": "layoutEntityID",
        /**
        * true: entity is displayed
        * false: entity is hidden
        */
        "enabled": true || false
    }
]

Reorder entities within a widget

First of all, keep in mind you can reorder entities that belong to the same level of nesting within your widget. When reordering one entity, you need to reorder its direct siblings (with the same parent_id) in order to avoid having siblings with the same order.

To reorder entities, send a PATCH request on /widgets/preferences-centers/layout-entities.

PATCH https://api.didomi.io/widgets/preferences-centers/layout-entities?organization_id=YOUR_ORG_ID
[
    {
        "id": "layoutEntityID",
        "order": 0
    },
    {
        "id": "layoutEntityID",
        "order": 1
    },
    ...
]

preference_value_id are not unique. What makes a preference value unique is the couple selected_preference_id and preference_value_id (Mind checking this section to fully understand how relation between preferences and selected preferences works)

When reordering preference values, make sure to target the right parent_id (aka the layout entity linked to the parent preference)

Last updated