kontent-ai / delivery-sdk-php

Kontent.ai Delivery SDK for PHP
https://kontent.ai
MIT License
46 stars 15 forks source link

Custom element type support #77

Closed petrsvihlik closed 3 years ago

petrsvihlik commented 5 years ago

Motivation

As new element type - Custom element - was added to Delivery output, it's needed to add its support to SDKs. Actually, it's already added to .NET SDK and code generator

Custom element stores its value as simple string. The format of the string is free and determined by the developer who creates element.

In Delivery output custom element has type "custom"

It should be supported in generator as well.

Proposed solution

The concrete solution depends on concrete SDK implementation. Generally, you should add Custom Element into list of supported types with type name "custom" and data type "string". Also you should add Custom element type into tests.

Additional context

An example of Delivery output with Custom element

{

"item": {
    "system": {
        "id": "9acff635-2dc5-4402-ab10-72575d734020",
        "name": "ColorPickerElement",
        "codename": "colorpickerelement",
        "language": "default",
        "type": "colorpickertype",
        "sitemap_locations": [],
        "last_modified": "2019-01-22T09:39:39.3095575Z"
    },
    "elements": {
        "colorpicker": {
            "type": "custom",
            "name": "ColorPicker",
            "value": "#d7e119"
        }
    }
},
"modular_content": {}

}