Catenis API Client for WordPress

Catenis API Client for WordPress enables (JavaScript) code on WordPress pages to interact with the Catenis API.
Enabling the Catenis API client
To enable the Catenis API client for a given WordPress page, go to the page’s edit page and look for a section (meta box) named “Catenis API Client” below the page’s main editing panel. Make sure the section is expanded, and check the Load Catenis API Client checkbox.
You can then choose to override the global settings used for instantiating the Catenis API client on that given page, like using a different device ID and its associated API access secret. Otherwise, whatever is configured in the plugin’s global settings — configured under “Settings” | “Catenis API Client” — is going to be used.
Using the Catenis API client
Once enabled, a global JavaScript variable named ctnApiClient is made available on the page. That variable holds the instantiated Catenis API client object.
Use the ctnApiClient variable to call the Catenis API methods by invoking the corresponding method on that object.
For a reference of the available methods, please refer to the Catenis API JavaScript Client as it is functionally identical to the Catenis API Client for WordPress, except for notifications support and error handling.
Notifications support
The notification feature on Catenis API Client for WordPress is almost identical to the one found on the Catenis API JavaScript client. The two noticeable differences are:
- The Catenis API client object can emit a
comm-errorevent. - The
openevent emitted by the WebSocket notification channel object may return an error.
Please refer to the “Receiving Notifications” section below for detailed information on how to receive Catenis notifications from within WordPress pages.
Error handling
Errors that take place while calling the Catenis API methods are returned as standard JavaScript Error objects.
Receiving Notifications
= Instantiate WebSocket notification channel object
Create a WebSocket notification channel for a given Catenis notification event.
var wsNotifyChannel = ctnApiClient.createWsNotifyChannel(eventName);
Add listeners
Add event listeners to monitor activity on the notification channel.
ctnApiClient.on('comm-error', function (error) {
// Error communicating with Catenis notification process
});
wsNotifyChannel.on('open', function (error) {
if (error) {
// Error establishing underlying WebSocket connection
}
else {
// Notification channel successfully open
}
});
wsNotifyChannel.on('error', function (error) {
// Error in the underlying WebSocket connection
});
wsNotifyChannel.on('close', function (code, reason) {
// Underlying WebSocket connection has been closed
});
wsNotifyChannel.on('notify', function (eventData) {
// Received notification
});
Note: the ‘comm-error’ event is emitted by the Catenis API client object while all other events are emitted by the WebSocket notification channel object.
Open the notification channel
Open the WebSocket notification channel to start receiving notifications.
wsNotifyChannel.open(function (error) {
if (err) {
// Error sending command to open notification channel
}
});
Close the notification channel
Close the WebSocket notification channel to stop receiving notifications.
wsNotifyChannel.close(function (error) {
if (err) {
// Error sending command to close notification channel
}
});
Download & install the zip archive
The plugin package installer can be downloaded from the WP2E project tab called “code”.
1 – Select the version to download if this option is available otherwise the “latest” version of the main plugin will be used.
2 – After downloading the zip archive install the plugin package installer in you local environment and activate the script from the plugin list.
3 – Under the section “Plugins” of the admin dashboard you should see a new “Dependencies & Licenses” link. Follow the instructions from this panel to finalize the installation of the missing dependencies.
- Give a name to your project
- Download the Installer Package
- Install & activate the plugin locally
- Install the suggested dependencies
Tips: Use the WP2E panel to add/suggest new dependencies to the local installation. Press F5 in the list of dependencies if the changes are not displayed right away.



