Vehicles
Vehicles and their attached data will work pretty much as documented in the IronAPI documentation.
According to the client which is logged in, their universe will list the available options to list and change the data.
Many entites have and "owning_customer" as attributes - it is optional and will be set automatically, so best to never show it in forms and never send them. Exception: when creating or changing a vehicle, owning_customer is required and needs to be set by the user.
Some entities are only available to certain client agendas (e.g. vehicle_note). Sending a query joining this entity will result in an error, so do not do this.
Example
List all vehicles, filter by band "Renault", join internal notes, attached files and their type definitions:
#!json
# POST {{url}}/data/core/vehicle/query
{
"conds" : {"me.brand" : "Renault"},
"attrs" : {
"prefetch" : ["core__vehicle_note__vehicle", {"core__vehicle_file__vehicle" : "vehicle_document_type"}]
}
}
Note that this query will fail for clients without "admin" or "employee" agendas, as they have no access to "vehicle_note".
core__vehicle_file__vehicle.id can be used to show a download button for the file. The Link will looks something like this
#!
{{url}}/data/core/file/3/download/file
Reowning a vehicle
To fulfil the requirement, that the data (vehicle_maintenance) stored should not be visible to the new owner of a vehicle, a new database entry with the same vin is created and the old entry gets the "reowned_id" set to the newly created entry.
To do this within one transaction, a plugin is provided:
#!json
POST https://garage.abocar.at/plugins/vehicle_reown
{
"vehicle_id" : 2,
"customer_id" : 5
}