#StatusCake API wrapper
StatusCake is a monitoring service that monitors website/servers over HTTP/TCP/PING.
This project wraps most endpoints StatusCake has to offer.
Via Composer
composer require happydemon/statuscake
Setting up the client:
$statusCake = new StatusCake\Client(`USER', 'TOKEN');
Checking if the credentials are valid:
$statusCake->validAccount(); // return true or false
Getting basic account info:
$statusCake->account();
These are actually your monitors, each test would represent a website you're monitoring.
Each returned test will be parsed into a class StatusCake\Test
, all the properties are documented in there, be sure to check it out.
To create a test you need to initialise StatusCake\Test
. There are just a few properties that are actually required; websiteName, websiteURL, testType.
$test = new StatusCake\Test();
// Required parameters
$test->websiteName = 'HappyDemon';
$test->websiteURL = 'http://happydemon.xyz';
$test->testType = StatusCake\Test::TYPE_HTTP;
// I'm a little impatient, so I'd like more frequest checks (every 2 minutes)
$test->checkRate = 120;
// Save everything
$statusCake->updateTest($test);
Updating is done in the same way:
// I've changed my mind, let's check every 5 minutes
$test->checkRate = 300;
// Save the change
$statusCake->updateTest($test);
$statusCake->deleteTest($test);
Retrieving a list of existing tests is simple:
$tests = $statusCake->getTests();
A period of data is two time stamps in which status has remained the same.
$periods = $test->getPeriods();
Retrieves a list of checks performed for the current site (this statusCake users with a premium account).
$periods = $test->getPerformance();
Retrieves a list of alerts that have, previously, been sent.
$periods = $test->getAlerts();
One of the properties tests could need assigned is contact groups. You can retrieve and manage them through the API as wel.
The same principles as Tests are applied here, meaning every contact group will be loaded in a StatusCake\ContactGroup
class (check the class definition for more info on the properties).
A few helper functions are included to work with email addresses.
$contactGroup = new StatusCake\ContactGroup();
// The only required parameter
$contactGroup->groupName = 'personal mail';
// let's add an email to get notifications
$contactGroup->addEmail('[email protected]');
// Save everything
$statusCake->updateContactGroup($contactGroup);
// I've changed my mind, different email
$contactGroup->removeEmail('[email protected]');
$contactGroup->addEmail('[email protected]');
// Which is the same as doing
$contactGroup->email = ['[email protected]']
// Save everything
$statusCake->updateContactGroup($contactGroup);
$statusCake->deleteContactGroup($contactGroup);