Fix Client Admin API docs/guards and correct Guest API test fixture typos (#3561)

* Initial plan

* fix client admin api docs and validation edge cases

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/4dcf2f2c-77f2-4343-83ef-ecd1e9d63d82

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* refactor currency assignment in client admin update

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/4dcf2f2c-77f2-4343-83ef-ecd1e9d63d82

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>
This commit is contained in:
Copilotandadmdly authored and GitHub committed 2026-05-16 12:10:11 +01:00
1 parent 3bd8e853b5
commit 09ce074384
2 files changed
+20 -17

No files matched your search

+11 -8
View File
@@ -47,11 +47,11 @@ class Admin extends \Api_Abstract
}
/**
* Get a list of clients.
* Get client ID/name pairs.
*
* @param array $data Filtering options
*
* @return array List of clients in a paginated manner
* @return array List of client ID/name pairs
*/
public function get_pairs($data)
{
@@ -156,7 +156,9 @@ class Admin extends \Api_Abstract
throw new InformationException('This email address is already registered.');
}
$validator->isPasswordStrong($data['password']);
if (isset($data['password']) && $data['password'] !== '') {
$validator->isPasswordStrong($data['password']);
}
$this->di['events_manager']->fire(['event' => 'onBeforeAdminClientCreate', 'params' => $data]);
$id = $service->adminCreateClient($data);
@@ -248,16 +250,17 @@ class Admin extends \Api_Abstract
unset($data['birthday']);
}
if (($data['currency'] ?? null) && $service->canChangeCurrency($client, $data['currency'] ?? null)) {
$client->currency = $data['currency'] ?? $client->currency;
$currency = $data['currency'] ?? null;
if ($currency && $service->canChangeCurrency($client, $currency)) {
$client->currency = $currency;
}
$this->di['events_manager']->fire(['event' => 'onBeforeAdminClientUpdate', 'params' => $data]);
// Special handling for the phone country codes
$phoneCC = $data['phone_cc'] ?? $client->phone_cc;
if (!empty($phoneCC)) {
$client->phone_cc = Tools::validatePhoneCC($phoneCC);
$phoneCountryCode = $data['phone_cc'] ?? $client->phone_cc;
if (!empty($phoneCountryCode)) {
$client->phone_cc = Tools::validatePhoneCC($phoneCountryCode);
}
// Special handling for the phone number itself