update_events

To mark a fuel filling or drain as false, or to remove such a mark, use the unit/update_events method.

Events marked as false are shown in reports only if the Show false events option is enabled in the report template settings.

Endpoint

Copied!
svc=unit/update_events&params={
    "events": [
        {
            "itemId": <long>,
            "resourceId": <long>,
            "eventType": <text>,
            "timeFrom": <uint>,
            "timeTo": <uint>,
            "params": {
                "mark": <uint>,
                "mark_type": <text>
            }
        }
    ]
}

Parameters

The request must contain the following parameters:

Parameter Description
events Array of events to update.
itemId Unit ID.
resourceId ID of the resource in which the executed report is stored.
eventType Type of event: lls (fuel level), theft (fuel drain), filling (fuel filling).
timeFrom Event beginning, UNIX time.
timeTo Event end, UNIX time.
params Object with the updated parameters.
mark False event mark: 1 to mark the event as false, 0 to remove the mark.
mark_type Subtype of the event to mark: fillings (fuel filling) or thefts (fuel drain). Required if eventType is lls.

Response

If the request is completed successfully, a response in the following format is returned:

Copied!
{
  "items": [
    {
      "itemId": <long>,   /* Unit ID. */
      "error": <uint>     /* Result for the event: 0 if the mark is updated, 7 if there is no access right. */
    }
  ]
}

The items array contains one object for each event from the request, in the same order.

The error field contains 7 if the user has no Create, edit, and delete report templates access right to the resource or no View object and its basic properties access right to the unit.

If the request fails, an error code is returned.

Error codes

Error code Description
4 Wrong input parameters.
7 The event service is unavailable. If there is no access right to the unit or resource, the error is returned for each event separately in the error field of the response.

Example

To mark two fuel filling events of the unit with ID 1285 as false, use the following request. The mark_type parameter is set to fillings so that only the fillings are marked, not any fuel drains registered at the same time:

Copied!
svc=unit/update_events&params={
  "events": [
    {
      "itemId": 1285,
      "resourceId": 123,
      "eventType": "lls",
      "timeFrom": 1689734883,
      "timeTo": 1689734883,
      "params": {
        "mark": 1,
        "mark_type": "fillings"
      }
    },
    {
      "itemId": 1285,
      "resourceId": 123,
      "eventType": "lls",
      "timeFrom": 1689737145,
      "timeTo": 1689737145,
      "params": {
        "mark": 1,
        "mark_type": "fillings"
      }
    }
  ]
}

The response contains one object for each event from the request. In this example, error: 0 for both events means that the false event mark was updated successfully:

Copied!
{
  "items": [
    {
      "itemId": 1285,
      "error": 0
    },
    {
      "itemId": 1285,
      "error": 0
    }
  ]
}

If you find a mistake in the text, please select it and press Ctrl+Enter.