Odometer

Methods presented in this part are available in the DriveKitVehicle class

Synchronize vehicle's odometer

You can retrieve the vehicle’s odometer data from the DriveQuant servers by calling the following method:

func getOdometer(
	vehicleId: String, 
	type: DKVehicleSynchronizationType = .defaultSync, 
	completionHandler: @escaping (DKOdometerSyncStatus, DKVehicleOdometer?, [DKVehicleOdometerHistory]?) -> Void
)

This method have the following parameters:

NameTypeDescription

vehicleId

String

The vehicle for which you want to get the odometer’s data

type

SynchronizationType

Can be defaultSync or cache.

- defaultSync will synchronize the vehicle’s odometer by calling the DriveQuant servers

- cache will retrieve the odometer data already synchronized in the local database.

DKOdometerSyncStatus, DKVehicleOdometer and DKVehicleOdometerHistory models are described in the References part.

Retrieve local vehicle’s odometer data

You can retrieve the vehicle’s odometer data stored in the DriveKit local database by calling the previous method but with the type parameter to cache.

Add odometer history

You can add a new entry to a vehicle’s odometer by calling the following method:

func addOdometerHistory(
    vehicleId: String,
    distance: Double,
    completionHandler: @escaping (DKOdometerAddHistoryStatus, DKVehicleOdometer?, [DKVehicleOdometerHistory]?) -> Void
)

This method have the following parameters:

NameTypeDescription

vehicleId

String

The vehicle id for which you want to add an history entry

distance

Double

The distance in km you want to set

DKOdometerAddHistoryStatus, DKVehicleOdometer and DKVehicleOdometerHistory models are described in the References part.

Update odometer history

To update an entry to a vehicle’s odometer, call the following method:

func updateOdometerHistory(
    vehicleId: String,
    historyId: String,
    distance: Double,
    completionHandler: @escaping (DKOdometerUpdateHistoryStatus, DKVehicleOdometer?, [DKVehicleOdometerHistory]?) -> Void
)

This method have the following parameters:

NameTypeDescription

vehicleId

String

The vehicle id for which you want to update the odometer’s data

historyId

String

The history id for which you want to update the distance.

distance

Double

The distance in km you want to update

DKOdometerUpdateHistoryStatus, DKVehicleOdometer and DKVehicleOdometerHistory models are described in the References part.

Delete odometer history

To delete vehicle’s odometer entry, call the following method:

func deleteOdometerHistory(
    vehicleId: String,
    historyId: String,
    completionHandler: @escaping (DKOdometerDeleteHistoryStatus, DKVehicleOdometer?, [DKVehicleOdometerHistory]?) -> Void
)

This method have the following parameters:

NameTypeDescription

vehicleId

String

The vehicle id for which you want to delete the odometer’s history entry

historyId

String

The history id you want to delete

DKOdometerDeleteHistoryStatus, DKVehicleOdometer and DKVehicleOdometerHistory models are described in the References part.

Last updated