Module Actions Template
Module Actions are used to trigger events on a remote system. For example, in the local billing system the user might have just ordered a fibre device, which means in the remote system, the device must be ordered. Communication with a remote system typically uses an API.
In order to interact with remote APIs, module actions are used. These are triggered in the local system as services are added to user accounts.
Actions
These are the module actions referred to when designing APIs:
Verb | Comment |
---|---|
Create | Create a new user in the remote system |
Suspend | Suspend a user in the remote system. Typical use might be due to non-payment, but could also be applicable if the user goes on holiday and the service needs to be temporary suspended. |
Unsuspend | Opposite of Suspend |
Terminate/Delete | Completely remove the service from the remote system |
Update Usage | Update the usage for a user. Typically used in a batch fashion to update all users |
Audit | Pull data (e.g. users) from a remote system and ensure it’s also available locally. If not, point this out |
Change password | Rarely used, but is useful if an end-user believes their service password was compromised and they require it to be reset |
Examples
Update Usage
The routine below first gets all users in a remote system, then does another query to retrieve the usage, and then updates the local system in two possible places:
<?php
public static function updateUsage()
{
$usage = IsApi::usageSummary();
foreach ($usage->data as $username => $attribute) {
foreach ($attribute->Packages as $package) {
if ($package->{'Data Type'} == 'Once Off') {
self::syncTopup($username, $package);
} elseif ($package->{'Data Type'} == 'Recurring') {
self::syncServiceUsage($username, $package);
}
}
}
return $usage;
}
Reference
https://developers.whmcs.com/provisioning-modules/supported-functions/