Core API

Item Processor

Item Processor is responsible for creating, receiving, updating and deleting items. Please note that you can not delete items from an application. When you delete the items they just marked as deleted.

Item Processor provides such methods for working with items:

  1. getItems

  2. addNewItems

  3. updateItems

  4. deleteItems

getItems

Method returns items from the application. It takes an application ID as an argument.

import GudHub from '@gudhub/core';
const gudhub = new GudHub(authkey);
gudhub.getItems(app_id, false);
Argument Name Type Description
app_id number application ID where we want to get the field model
trash boolean if it's true then it returns deleted items only

The Method returns items:

[
    {
    "item_id": 2987986,
    "fields": [{
            "element_id": 645888,
            "field_value": "John",
        }],
    },
    {
    "item_id": 2987996,
    "fields": [{
            "element_id": 645888,
            "field_value": "Johana",
        }]
    }
]

addNewItems

The method adds a new item in the items list. It takes application ID and an item list as arguments.

import GudHub from '@gudhub/core';
const gudhub = new GudHub(authkey);
let itemsList = [{
  "item_id": 2987986,
  "fields": [{
        "element_id": 645888,
        "field_value": "John",
      }],
  },
  {
  "item_id": 2987996,
  "fields": [{
        "element_id": 645888,
        "field_value": "Johana",
      }]
  }
];

gudhub.addNewItems(app_id, itemsList);
Argument Name Type Description
app_id number application ID where we want to get the field model
itemsList array array of application items

In response, we will get a new item object:

[
    {
    "item_id": 2987986,
    "fields": [{
            "element_id": 645888,
            "field_value": "John",
        }],
    },
    {
    "item_id": 2987996,
    "fields": [{
            "element_id": 645888,
            "field_value": "Johana",
        }]
    }
]

updateItems

The method is called for updating an existing item. It takes application ID and items list as arguments.

import GudHub from '@gudhub/core';
const gudhub = new GudHub(authkey);
let itemsList = [{
  "item_id": 2987986,
  "fields": [{
        "element_id": 645888,
        "field_value": "John",
      }],
  },
  {
  "item_id": 2987996,
  "fields": [{
        "element_id": 645888,
        "field_value": "Johana",
      }]
  }
];

gudhub.updateItems(app_id, itemsList);
Argument Name Type Description
app_id number application ID where we want to get the field model
itemsList array array of application items

It returns updated item object:

[
    {
    "item_id": 2987986,
    "fields": [{
            "element_id": 645888,
            "field_value": "John",
        }],
    },
    {
    "item_id": 2987996,
    "fields": [{
            "element_id": 645888,
            "field_value": "Johana",
        }]
    }
]

deleteItems

This method is called for deleting existed items. As arguments, it takes application ID and items list.

import GudHub from '@gudhub/core';
const gudhub = new GudHub(authkey);
gudhub.deleteItems(app_id, itemsIds);
Argument Name Type Description
app_id number application ID where we want to get the field model
itemsList array array of application items

As a result we get a success message:

delete item list with id = [2904512]. Ok