Core API

Field Processor

Field processor is responsible for receiving, updating fields models. Also with field processor you can get and update field values.

All field methods are collected and described in this article:

  1. getField

  2. updateField

  3. deleteField

  4. getFieldModels

  5. getFieldValue

  6. setFieldValue

getField

Due to this method you can get field from the relevant application. It takes application and field IDs as arguments.

import GudHub from '@gudhub/core';
const gudhub = new GudHub(authkey);

let app_id = 23;
let field_id = 34212;

let gottenField = await gudhub.getField(app_id, field_id);
console.log(gottenField)
Argument Name Type Description
app_id number application ID where we want to get the field model
field_id number field ID that we want to receive

Method returns promise with field model from specific application:

{
    "app_id": 23,
    "field_id": 505247,
    "data_type": "image",
    "name_space": "thumbnail",
    "field_priority": 0,
    "field_name": "Thumbnail",
    "data_model": {...}
}

updateField

This method allows you to update field model of the current application. It take two arguments:

import GudHub from '@gudhub/core';
const gudhub = new GudHub(authkey);

let app_id = 23;
let fieldModel = {"app_id": 23,
    "field_id": 505247,
    "data_type": "image",
    "name_space": "thumbnail",
    "field_priority": 0,
    "field_name": "Thumbnail",
    "data_model": {...}
};

let updatedField = await gudhub.updateField(app_id, fieldModel);
console.log(updatedField)
Argument Name Type Description
app_id number application ID where we want to update the field model
fieldModel object contains existing field data

The method returns a promise that in turn returns an updated field model:

{
    "app_id": 23,
    "field_id": 505247,
    "data_type": "image",
    "name_space": "thumbnail",
    "field_priority": 0,
    "field_name": "Thumbnail",
    "data_model": {...}
}

deleteField

The method is responsible for deleting field from the application. Its arguments are application and field IDs.

import GudHub from '@gudhub/core';
const gudhub = new GudHub(authkey);

let app_id = 23;
let field_id = 34545;

let deletedField = await gudhub.deleteField(app_id, field_id);
console.log(deletedField)
Argument Name Type Description
app_id number application ID where we want to delete the field model
field_id number unique field ID

In response, we will get a promise, and it returns the model of the deleted field.

{
    "app_id": 23,
    "field_id": 34545,
    "data_type": "text",
    "name_space": "first-name",
    "field_priority": 0,
    "field_name": "First Name",
    "data_model": {...}
}

getFieldModels

This method is used for getting a list of field models. It takes applications ID as an argument.

import GudHub from '@gudhub/core';
const gudhub = new GudHub(authkey);

let app_id = 23;

let fieldModels = await gudhub.getFieldModels(app_id);
console.log(fieldModels)
Argument Name Type Description
app_id number application ID where we want to get the field models

It returns a response with an array of application field models.

[{
    "app_id": 7054,
    "field_id": 82381,
    "field_id": 82381,
    "name_space": "app",
    "field_priority": 0,
    "name_space": "app",
    "data_model": {...},
    "interpretation": [],
    "item_update_settings": {...},
    "itself_filter": {...},
    "search": "",
},…]

getFieldValue

This method is responsible for getting the value from the desired field. It takes application, item and field IDs as arguments.

import GudHub from '@gudhub/core';
const gudhub = new GudHub(authkey);

let app_id = 23;
let item_id = 22432;
let field_id = 111212;

let fieldValue = await gudhub.getFieldValue(app_id, item_id, field_id);
console.log(fieldValue)
Argument Name Type Description
app_id number application ID where we want to get the field model
item_id number item ID where we want to get the field model
field_id number unique field ID

The method returns promise that returns value from desired field:

"value"

setFieldValue

This method is called to set value in the desired field. It takes application, item, and field IDs and, of course, the very value as arguments.

import GudHub from '@gudhub/core';
const gudhub = new GudHub(authkey);

let app_id = 23;
let item_id = 22432;
let field_id = 111212;
let field_value = "new";

let setFieldValue = await gudhub.setFieldValue(app_id, item_id, field_id, field_value);
console.log(setFieldValue)
Argument Name Type Description
app_id number application ID where we want to set field value
item_id number item ID where we want to set field value
field_id number field ID where we want to set field value
field_value string value to be set in the field

The method returns promise that in turn returns the set value.

"new"