Template HTTP

HTTP template configuration

The HTTP template doesn't need any particular configuration. Once the HTTP template type has been selected, it is possible to start the transmission. 

Transmitting to a template

Data must be forwarded to https://api.databoom.com/v1/signals/push/<unique arbitrary value>. 

Data format to use is the following:

{
    "type": "data",
    "message":  [
      {
        "template": "<HTTP template token>",
        "date": "2018-04-12T15:00:00.000Z",
        "signals": [
          {
            "name": "<signal 1 token>",
            "value": <signal 1 value>
          },
          {
            "name": "<signal 2 token>",
            "value": <signal 2 value>
          }
        ]
      }
    ]
}

Data publication implies:

  • If there weren't previous communications, the creation of a new device with the token <HTTP template token>-<unique arbitrary value> where:
    • <HTTP template token> is inside the message and corresponds to the reference template;
    • <unique arbitrary value> is the value set by the user in the address.
    The device will be populated withe the same signals of the template (new signals with the same tokens), regardless their values being sent or less. The signals are already validated and ready to communicate. If signals contains signals not appearing in the template, they're added only to the device, waiting for validation;
  • If there were previous communications, the update of <template token>-<unique arbitrary value> with values in signals. If a new signal has been added to the template, it is also created in the device;
  •  message is an array, is therefore possible to create/communicate with more devices per publication, provided that they refer to different devices.

Transformation function for published data

If published data content can't be customized according to Databoom accepted format (in the previous paragraph), it is possible to specify a transformation function to process the payload an make it compatible to the platform.

The function must return one or more values (array []) in the accepted format:

{
    'date': <DATE>,
    'value': <VALUE>
}

o

{
    'value': <VALUE>
}

o

<VALUE>

In case of array, components can use different formats.

In the example you can see the function doIt 

function doIt(payload) {    
return { 'date': new Date(), 'value': (payload[1].charCodeAt(0) - 97)
}; }

payload parameter allows to access the published data and process them in order to return them in a compatible format. In the example the value is calculated by subtracting 97 to the code of the first character of the first payload component.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.