-
Read src/LiteSpeed.php to confirm the action name and param names expected by the LiteSpeed eService API. Verify the method does not already exist before adding.
-
Add the PHPDoc block directly above the method. Follow the @param / @return style used by cancel() and upgrade():
-
Write the method signature with false defaults for optional params (matches suspend(), cancel(), upgrade()):
public function myAction($serial = false, $ipAddress = false, $optionalParam = false)
{
-
Validate required enum inputs first, before touching $this->params. Return early on failure:
if (!in_array($cpu, $this->validCpu)) {
return ['error' => 'Invalid CPU'];
}
if (!in_array($payment, $this->validPayment)) {
return ['error' => 'Invalid Payment Method'];
}
Verify all validation guards are in place before proceeding.
-
Set params conditionally for optional values (use the !== false guard), unconditionally for required ones:
$this->params['license_serial'] = $serial;
if ($ipAddress !== false) {
$this->params['server_ip'] = $ipAddress;
}
if ($optionalParam !== false) {
$this->params['my_param'] = $optionalParam;
}
Param key names must match the LiteSpeed eService API field names exactly (e.g. license_serial, server_ip, reason, order_payment, upgrade_cpu).
-
Call $this->req() as the final statement, passing the PascalCase action string that the API expects:
return $this->req('MyAction');
Verify the action string matches the API spec (existing examples: 'Ping', 'Order', 'Cancel', 'ReleaseLicense', 'Suspend', 'Unsuspend', 'Upgrade', 'Query').
-
Run tests to confirm nothing is broken:
vendor/bin/phpunit --bootstrap vendor/autoload.php tests/ -v