Notification Module Interface

All Notification modules must implement this interface

interface NotificationModuleInterface

Methods summary

Return Type Method Name Description
array settings() List of settings required for module activation/configuration
bool isActive() Is this notification provider active?
string getName() Returns bare class name of the specific notification module.
string getDisplayName() Get display name for the notification module.
string getLogoPath() Logo of provider.
bool testConnection(array $settings) Routine to validate settings for activation/configuration of notification provider
array notificationSettings() List of settings relevant to the delivery of a notification
array getDynamicField(string $fieldName, array $settings) Retrieve option values used to populate a 'dynamic' Type notification setting
sendNotification(NotificationInterface $notification, array $moduleSettings, array $notificationSettings) Deliver notification

Details

array settings ()

List of settings required for module activation/configuration

EX. return [ 'api_username' => [ 'FriendlyName' => 'API Username', 'Type' => 'text', 'Description' => 'Required username to authenticate with message service', ], 'api_password' => [ 'FriendlyName' => 'API Password', 'Type' => 'text', 'Description' => 'Required password to authenticate with message service', ], ];

Return Value

array

bool isActive ()

Is this notification provider active?

Return Value

bool

string getName ()

Returns bare class name of the specific notification module.

EX. 'Hipchat' or 'Aim' or 'MyMessageModerator'

Return Value

string

string getDisplayName ()

Get display name for the notification module.

Return Value

string

string getLogoPath ()

Logo of provider.

Publicly accessible path relative to WHMCS System URL. Expressed as "absolute" path (leading forward slash) EX. '/modules/notifications/messagemod/messagemod.png'

Return Value

string

bool testConnection (array $settings)

Routine to validate settings for activation/configuration of notification provider

Parameters

array $settings

Return Value

bool Return true for success

array notificationSettings ()

List of settings relevant to the delivery of a notification

EX. ['channel' => [ 'FriendlyName' => 'Channel', 'Type' => 'dynamic', 'Description' => 'Select the desired channel for notification delivery.', 'Required' => true, ], ]

Return Value

array

array getDynamicField (string $fieldName, array $settings)

Retrieve option values used to populate a 'dynamic' Type notification setting

Parameters

string $fieldName Notification setting field name
array $settings Settings for the module

Return Value

array

See also

notificationSettings() EX. if ($fieldName == 'channel') { return [ 'values' => [ ['id' => 1, 'name' => 'Tech Support'], ['id' => 2, 'name' => 'Customer Service'], ],]; } elseif ($fieldName == 'botname') { $restClient = $this->factoryHttpClient($settings); $operators = $restClient->get('/operators'); return ['values' => $operators->toArray()]; }

sendNotification (NotificationInterface $notification, array $moduleSettings, array $notificationSettings)

Deliver notification

Parameters

NotificationInterface $notification A notification to send
array $moduleSettings Configured settings of the notification module
array $notificationSettings Configured notification settings set by the triggered rule

Exceptions

Exception on error