Add deleteVehicle method to XLVask endpoints and update route logic to use it
This commit is contained in:
@@ -155,6 +155,29 @@ abstract class xlvask_endpoints extends xlvask_request implements xlvask_endpoin
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @throws Exception If the module is not enabled
|
||||
* @throws Exception If the username is not set
|
||||
* @throws Exception If the password is not set
|
||||
* @throws Exception If the response is not valid JSON
|
||||
* @throws Exception If the response is not successful
|
||||
* @throws Exception If there is an error with the request
|
||||
* @throws Exception If the vehicle data is not valid
|
||||
* @throws Exception If the vehicle update fails
|
||||
* @note This method deletes a vehicle from the XLVask API. (This is an irreversible destructive action.)
|
||||
*/
|
||||
public function deleteVehicle(xlvask_vehicle $xlvaskVehicle): array
|
||||
{
|
||||
$url = $this->config->api_url . '/vehicles/' . $xlvaskVehicle->vehicleId;
|
||||
return $this->sendRequest(
|
||||
$url,
|
||||
'DELETE',
|
||||
[],
|
||||
[self::getAuthHeader(),]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @throws Exception If the module is not enabled
|
||||
|
||||
@@ -69,7 +69,13 @@ interface xlvask_endpoints_i
|
||||
* @return array
|
||||
*/
|
||||
public function updateVehicle(xlvask_vehicle $xlvaskVehicle): array;
|
||||
|
||||
|
||||
/**
|
||||
* Delete a vehicle from the xlvask API
|
||||
* @param xlvask_vehicle $xlvaskVehicle
|
||||
* @return array
|
||||
*/
|
||||
public function deleteVehicle(xlvask_vehicle $xlvaskVehicle): array;
|
||||
|
||||
/**
|
||||
* Get the auth header for the xlvask API
|
||||
|
||||
@@ -211,7 +211,7 @@ class moduleXLVaskRoute
|
||||
// Print the vehicles
|
||||
print_r($vehicle);
|
||||
$vehicle->vehicleTypeId = (new $xlvask->helpers->xlvask_vehicle_types())->getVehicleTypesByProductId(2)[0]->vehicleTypeId;
|
||||
$result = $xlvask->updateVehicle($vehicle);
|
||||
$result = $xlvask->deleteVehicle($vehicle);
|
||||
print_r($result);
|
||||
// $vehicle = new $xlvask->helpers->xlvask_vehicle();
|
||||
// /** @var xlvask_vehicle $vehicle */
|
||||
|
||||
Reference in New Issue
Block a user