Assegnazione dei driver API

1. Descrizione

L’API per l’assegnazione dei conducenti รจ utilizzata per assegnare i conducenti agli oggetti (veicoli). Questo permette agli utenti web che hanno generato la loro chiave API di creare assegnazioni di conducenti o di ottenere le ultime assegnazioni utilizzando le chiamate API.

2. API versione 1

2.1. Crea assegnazione
2.1.1. Richiesta con data e ora

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. Richiesta senza datetime

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. Risposta per la richiesta corretta

{
    "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. Risposte per richieste non corrette

{
    "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. Ottieni l’ultima assegnazione
2.2.1. Richiesta perObjectID

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. Esempio perObjectID

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. Richiesta 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. Esempio perDriverId

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. Risposta per la richiesta corretta

{
    "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. Risposte per richieste non corrette

{
    "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