Add createCustomer method to XLVask endpoints, update interface, and refine imports.

This commit is contained in:
Jepp9350
2025-06-17 19:14:12 +02:00
parent 43f0cd3a25
commit c94537ecab
2 changed files with 30 additions and 0 deletions
@@ -5,6 +5,7 @@ require_once WD . '/modules/xlvask/interfaces/xlvask_endpoints_i.php';
require_once WD . '/modules/xlvask/classes/xlvask_request.php';
use Exception;
use helpers\xlvask_customer;
use helpers\xlvask_vehicle;
use xlvask\interfaces\xlvask_endpoints_i;
@@ -204,4 +205,24 @@ 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
*/
public function createCustomer(xlvask_customer $xlvaskCustomer): array
{
$url = $this->config->api_url . '/customers';
return $this->sendRequest(
$url,
'POST',
$xlvaskCustomer->toArray(),
[self::getAuthHeader(),]
);
}
}
@@ -3,6 +3,7 @@
namespace xlvask\interfaces;
use Exception;
use helpers\xlvask_customer;
use helpers\xlvask_vehicle;
interface xlvask_endpoints_i
@@ -56,6 +57,14 @@ interface xlvask_endpoints_i
bool|null $users = null,
): array;
/**
* Create a new customer in the xlvask API
* @param xlvask_customer $xlvaskCustomer
* @return array
*/
public function createCustomer(xlvask_customer $xlvaskCustomer): array;
/**
* Create a new vehicle in the xlvask API
* @param xlvask_vehicle $xlvaskVehicle