@vulog/aima-vehicle
v1.2.46
Published
Vehicle and model management — CRUD operations, real-time data, services, and options.
Readme
@vulog/aima-vehicle
Vehicle and model management — CRUD operations, real-time data, services, and options.
Installation
npm install @vulog/aima-vehicle @vulog/aima-client @vulog/aima-coreUsage
import { getVehicles, getVehicleById, getVehiclesRealTime } from '@vulog/aima-vehicle';
import { getClient } from '@vulog/aima-client';
const client = getClient({ ... });
const vehicles = await getVehicles(client);
const vehicle = await getVehicleById(client, 'vehicle-uuid');
const realTime = await getVehiclesRealTime(client, 500, Date.now() - 3600_000);API Reference
getModelsById
getModelsById(client: Client, id: number): Promise<Model>Fetches a single vehicle model by ID.
| Param | Type | Description |
| -------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| id | number | Model identifier |
getModelByIdAssets
getModelByIdAssets(client: Client, id: number): Promise<Assets>Returns EDS assets for a model.
| Param | Type | Description |
| -------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| id | number | Model identifier |
getModels
getModels(client: Client): Promise<Model[]>Returns all vehicle models for the fleet.
| Param | Type | Description |
| -------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
getVehicleById
getVehicleById(client: Client, id: string): Promise<Vehicle | null>Fetches a vehicle by ID. Returns null on 404.
| Param | Type | Description |
| -------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| id | string | Vehicle identifier |
getVehicleRealTimeById
getVehicleRealTimeById(client: Client, id: string): Promise<VehicleRealTime | null>Returns real-time telemetry for a vehicle. Returns null on 404.
| Param | Type | Description |
| -------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| id | string | Vehicle identifier |
getVehicleByIdAssets
getVehicleByIdAssets(client: Client, id: string): Promise<Assets>Returns EDS assets for a vehicle.
| Param | Type | Description |
| -------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| id | string | Vehicle identifier |
getVehicles
getVehicles(client: Client, pageSize?: number): Promise<Vehicle[]>Returns all vehicles in the fleet. Auto-paginates up to 50 pages using the given page size (default 500).
| Param | Type | Description |
| ---------- | -------- | ---------------------------------- |
| client | Client | Authenticated AIMA client |
| pageSize | number | Results per page (default 500) |
getVehiclesRealTime
getVehiclesRealTime(client: Client, pageSize?: number, lastUpdatedMillis?: number): Promise<VehicleRealTime[]>Returns real-time data for all vehicles. Auto-paginates up to 50 pages. lastUpdatedMillis must be a past UTC timestamp in milliseconds.
| Param | Type | Description |
| ------------------- | -------- | --------------------------------------- |
| client | Client | Authenticated AIMA client |
| pageSize | number | Results per page (default 500) |
| lastUpdatedMillis | number | Only return vehicles updated after this |
pingVehicleById
pingVehicleById(client: Client, id: string): Promise<boolean>Checks whether a vehicle's box is connected. Returns true if connected.
| Param | Type | Description |
| -------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| id | string | Vehicle identifier |
enableVehicle
enableVehicle(client: Client, vehicleId: string, payload: EnableVehicleBody): Promise<void>Enables a vehicle.
| Param | Type | Description |
| ----------- | ------------------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| vehicleId | string | Vehicle identifier |
| payload | EnableVehicleBody | Enable payload |
disableVehicle
disableVehicle(client: Client, vehicleId: string, payload: DisableVehicleBody): Promise<void>Disables a vehicle.
| Param | Type | Description |
| ----------- | -------------------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| vehicleId | string | Vehicle identifier |
| payload | DisableVehicleBody | Disable payload |
getModelVehicles
getModelVehicles(client: Client, options?: PaginableOptions): Promise<PaginableResponse<ModelVehicle>>Returns a paginated list of model-to-vehicle mappings.
| Param | Type | Description |
| --------- | ------------------ | ------------------------- |
| client | Client | Authenticated AIMA client |
| options | PaginableOptions | Pagination options |
createVehicle
createVehicle(client: Client, body: CreateVehicleBody): Promise<Vehicle>Creates a new vehicle in the fleet.
| Param | Type | Description |
| -------- | ------------------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| body | CreateVehicleBody | Vehicle creation data |
addServiceForVehicle
addServiceForVehicle(client: Client, serviceId: string, vehicleId: string): Promise<void>Assigns a service to a vehicle.
| Param | Type | Description |
| ----------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| serviceId | string | Service identifier |
| vehicleId | string | Vehicle identifier |
removeServiceForVehicle
removeServiceForVehicle(client: Client, serviceId: string, vehicleId: string): Promise<void>Removes a service from a vehicle.
| Param | Type | Description |
| ----------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| serviceId | string | Service identifier |
| vehicleId | string | Vehicle identifier |
getOptions
getOptions(client: Client): Promise<Options[]>Returns all vehicle options available in the fleet.
| Param | Type | Description |
| -------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
addOptionForVehicle
addOptionForVehicle(client: Client, vehicleId: string, optionId: number): Promise<Vehicle>Adds an option to a vehicle. Returns the updated vehicle.
| Param | Type | Description |
| ----------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| vehicleId | string | Vehicle identifier |
| optionId | number | Option identifier |
removeOptionForVehicle
removeOptionForVehicle(client: Client, vehicleId: string, optionId: number): Promise<Vehicle>Removes an option from a vehicle. Returns the updated vehicle.
| Param | Type | Description |
| ----------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| vehicleId | string | Vehicle identifier |
| optionId | number | Option identifier |
Types
Vehicle
Fleet vehicle data including id, name, plate, vin, model, options, fleetId, published, archived, noBox, msisdn, iccid, and optional wakeupProvider, imsi, residualValue.
VehicleRealTime
Real-time vehicle telemetry including location, battery, booking state, door/window status, zone membership, and box connectivity.
Model
Vehicle model definition including id, name, energyType, vehicleType, transmission, nbOfSeats, autonomy, fleetId.
Assets
{
fleet_id: string;
model_id: number;
assets: {
aid: string;
type: string;
url: string;
value: string;
b_value: string;
text: string;
}[];
}ModelVehicle
{
serviceId: string;
serviceVisibility: 'PUBLIC' | 'PRIVATE';
modelId: number;
vehicles: string[];
}CreateVehicleBody
Vehicle creation data. Optional fields include wakeupProvider, archived, msisdn, iccid, imsi, residualValue.
EnableVehicleBody / DisableVehicleBody
Payloads for enabling and disabling a vehicle.
Options
{
id: number;
fleetId: string;
name: string;
type: string;
description: string;
}