API за присвояване на водачи

1. Описание

API за присвояване на водачи се използва за присвояване на водачи към обекти (превозни средства). Това позволява на уебпотребителите, които са генерирали своя API ключ, да създават назначения на водачи или да получават последните назначения, като използват API повиквания.

2. API версия 1

2.1. Създаване на задание
2.1.1. Заявка с дата

POST /driver/assignations?version=1&api_key=<...>
HOST: api.fm-track.com
Content-Type: application/json;charset=UTF-8
 
BODY:
    {
    "driver_id": "240afea1-84ae-43ec-8139-f13cfa2f3094",
    "object_id": "7bf8990c-dba6-11e9-bdfc-1ff21de66015",
    "event_type": "START"
    "datetime":"2021-07-01T08:50:23.893Z"
    }

2.1.2. Заявка без дата

POST /driver/assignations?version=1&api_key=<...>
HOST: api.fm-track.com
Content-Type: application/json;charset=UTF-8
 
BODY:
    {
    "driver_id": "240afea1-84ae-43ec-8139-f13cfa2f3094",
    "object_id": "7bf8990c-dba6-11e9-bdfc-1ff21de66015",
    "event_type": "START"
    }
 ParameterTypeDescriptionIs requiredValidation
1versionstringVersion of API+
2api_keystringUser identification key +
3driver_idstringDriver identifier, External driver ID +
4object_idstringObject identifier, External object ID +
5event_typestringEvent type +Possible values: START, STOP
6datetimestringDatetime for START or STOP event -ISO 8601 datetime

2.1.3. Отговор за правилна заявка

{
    "object_id":"7bf8990c-dba6-11e9-bdfc-1ff21de66015",
    "driver_id":"240afea1-84ae-43ec-8139-f13cfa2f3094",
    "event_type":"START",
    "datetime":"2021-07-01T08:50:23.893Z"
}
 ParameterTypeDescription
1driver_idstringDriver identifier, External driver ID
2object_idstringObject identifier, External object ID
3event_typestringEvent type
4datetimestringDatetime of START or STOP event

2.1.4. Отговори за некоректна заявка

{
    "code": 422,
    "message": "Validation failed, see 'fieldValidationErrors' for more details",
    "field_validation_errors": [
        {
            "field": "objectId",
            "reason": "must not be empty",
            "rejected_value": "<null value>"
        },
        {
            "field": "driverId",
            "reason": "must not be empty",
            "rejected_value": "<null value>"
        },
        {
            "field": "eventType",
            "reason": "must not be null",
            "rejected_value": "<null value>"
        }
    ]
}
{
    "code": 400,
    "message": "Please provide valid driver assignation event type START|STOP"
}
{
    "code": 400,
    "message": "Invalid format: \"1993 05 04\" is malformed at \" 05 04\""
}
{
    "code": 404,
    "message": "Object with id 7bf8990c-dba6-11e9-bdfc-1ff21de66015asdasdasdasdasdadas not found"
}
{
    "code": 404,
    "message": "Driver with id 240afea1-84ae-43ec-8139-f13casfa2f3094 not found"
}
ParameterDescription
codeError code
400 - server cannot or will not process the request due to an apparent client error;
404 - requested resource could not be found but may be available in the future;
messageError code message

2.2. Получаване на последното присвояване
2.2.1. Запитване byObjectID

GET /driver/assignations/last?version=1&byObjectId={objectId}&api_key=<...>
HOST: api.fm-track.com
Content-Type: application/json;charset=UTF-8

2.2.2. Пример byObjectID

GET /driver/assignations/last?version=1&byObjectId=7bf8990c-dba6-11e9-bdfc-1ff21de66015&api_key=L6fwb1xODwA95qF7ybXJ4S2cSM49h1Wj
HOST: api.fm-track.com
Content-Type: application/json;charset=UTF-8

2.2.3. Заявка byDriverId

GET /driver/assignations/last?version=1&byDriverId={driverId}&api_key=<...>
HOST: api.fm-track.com
Content-Type: application/json;charset=UTF-8

2.2.4. Пример byDriverId

GET /driver/assignations/last?version=1&byDriverId=240afea1-84ae-43ec-8139-f13cfa2f3094&api_key=L6fwb1xODwA95qF7ybXJ4S2cSM49h1Wj
HOST: api.fm-track.com
Content-Type: application/json;charset=UTF-8

 

 ParameterTypeDescriptionIs requiredValidation
1versionstringVersion of API+
2api_keystringUser identification key+
3byDriverIdstringDriver identifier, External driver ID+Either byDriverId or byObjectId is required
4byObjectIdstringObject identifier, External object ID+Either byDriverId or byObjectId is required

2.2.5. Отговор за правилна заявка

{
    "object_id":"7bf8990c-dba6-11e9-bdfc-1ff21de66015",
    "driver_id":"240afea1-84ae-43ec-8139-f13cfa2f3094",
    "event_type":"STOP",
    "datetime":"2021-07-01T08:50:28.893Z"
}

 

 ParameterTypeDescription
1driver_idstringDriver identifier, External driver ID
2object_idstringObject identifier, External object ID
3event_typestringEvent type
4datetimestringDatetime of START or STOP event

2.2.6. Отговори за некоректна заявка

{
    "code": 400,
    "message": "No query parameters were provided. Provide query parameters byDriverId or byObjectId"
}
{
    "code": 404,
    "message": "Driver assignation event by driver id 8200f935-4970-43e3-8ab2-220c7f6463f4 not found"
}
{
    "code": 404,
    "message": "Driver with id 240afea1-84ae-43ec-8139-f13cfa2f3a094 not found"
}
{
    "code": 404,
    "message": "Object with id 7bf8990c-dba6-11de9-bdfc-1ff21de66015 not found"
}
ParameterDescription
codeError code
400 - server cannot or will not process the request due to an apparent client error;
404 - requested resource could not be found but may be available in the future;
messageError code message