🚐Crafting Metadata

With metadata, you can add additional parameters that an endpoint doesn't accept naturally on Terraswitch's API. Crafting metadata will depend on your language's handling of JSON and the intelligence behind how you process the properties.

The only way to add metadata is to add an array of objects called 'metadata' with its JSON structure of objects to an endpoint that accepts metadata

Structure of metadata objects

Metadata is an array of objects with a JSON structure. This structure can be constructive ( i.e. following Terraswitch's object structure) or dynamic. Dynamic structures mean you pass in your own defined objects; this should be an array of key/value pair objects. Constructive structure means you follow Terraswitch's defined structure.

Sample Dynamic Structure

[
   {
      "schoolName": "Grace Intl",
      "MatricNo": "110441"
   },
   {
      "orderId": "123456789",
      "vendor": "[email protected]"
   }
]

Constructive Structure

Constructive structures allow you to define "custom fields" that will be displayed on your Terraswitch dashboard and as well help you build flexible systems with additional information.

property
Datatype
Description

displayName

string

Specify the name you want to be displayed. E.g. "Order ID"

variableName

string

Specify the variable name. E.g. "orderId"

value

string

Specify the value of the variable. E.g. "1234567XDT"

Please note that each object in a metadata is in a key/value pair structure and they're expected to contain data. Should in case one of the three properties in displayName, variableName and value is not present, the system will not save the metadata object.

Sample Constructive Structure

[
    {
        "displayName": "Order ID",
        "variableName": "orderId",
        "value": "1234567XDT"
    },
    {
        "displayName": "Matric No",
        "variableName": "matricNumber",
        "value": "110441"
    }
]

Last updated