External Service Integrations
The Suma Management plugin connects to numerous external services for data synchronization, monitoring, and project management.
Asana
Purpose
Project and task management for client work.
Configuration
| Setting | Value |
|---|---|
| Library | asana/asana ^0.10 |
| Workspace ID | 93834251219403 |
| Team ID | 101071044814588 |
| Authentication | Personal Access Token |
Usage
namespace Suma;
class Asana {
private \Asana\Client $client;
public function __construct() {
$this->client = \Asana\Client::accessToken(
get_option('suma_asana_token')
);
}
/**
* Creates a new Asana task in the configured workspace.
*
* @param string $name Task name.
* @param string $notes Task description.
* @param string $project_gid Asana project GID.
* @return object Created task object.
*/
public function create_task(string $name, string $notes, string $project_gid): object {
return $this->client->tasks->createTask([
'workspace' => '93834251219403',
'name' => $name,
'notes' => $notes,
'projects' => [$project_gid],
]);
}
}
Cron Integration
check-for-new-sheets-projects.php creates Asana tasks when new projects are added to Google Sheets.
Google APIs
Services Used
| Service | Purpose |
|---|---|
| Google Sheets | Project tracking spreadsheet auto-population |
| Google Analytics | Site traffic data (UA and GA4) |
| Google Tag Manager | Container management |
Authentication
Uses a service account with JSON key file:
namespace Suma;
class Google {
private \Google_Client $client;
public function __construct() {
$this->client = new \Google_Client();
$this->client->setAuthConfig(
plugin_dir_path(__FILE__) . 'credentials/service-account.json'
);
$this->client->setScopes([
\Google_Service_Sheets::SPREADSHEETS,
\Google_Service_Analytics::ANALYTICS_READONLY,
]);
}
}
Google Sheets Integration
/**
* Appends a row to the project tracking spreadsheet.
*
* @param string $spreadsheet_id Google Sheets ID.
* @param array $row_data Row values to append.
* @return void
*/
public function append_row(string $spreadsheet_id, array $row_data): void {
$service = new \Google_Service_Sheets($this->client);
$body = new \Google_Service_Sheets_ValueRange([
'values' => [$row_data],
]);
$service->spreadsheets_values->append(
$spreadsheet_id,
'Sheet1!A:Z',
$body,
['valueInputOption' => 'USER_ENTERED']
);
}
Cron Scripts
check-for-new-sheets-projects.php— Reads new rows from project sheetgoogle-sheet-feature-update.php— Syncs feature data to/from sheets
Cloudflare
Purpose
DNS management, SSL certificate verification, and CDN cache control for managed sites.
Configuration
| Setting | Value |
|---|---|
| Library | cloudflare/sdk ^1.1.6 |
| Authentication | API Token (per-zone permissions) |
Usage
namespace Suma;
use Cloudflare\API\Auth\APIToken;
use Cloudflare\API\Adapter\Guzzle;
use Cloudflare\API\Endpoints\Zones;
use Cloudflare\API\Endpoints\DNS;
class Cloudflare {
private Zones $zones;
private DNS $dns;
public function __construct() {
$token = new APIToken(get_option('suma_cloudflare_token'));
$adapter = new Guzzle($token);
$this->zones = new Zones($adapter);
$this->dns = new DNS($adapter);
}
/**
* Gets all zones (domains) in the Cloudflare account.
*
* @return array Zone data array.
*/
public function get_all_zones(): array {
return $this->zones->listZones()->result;
}
/**
* Purges the CDN cache for a specific zone.
*
* @param string $zone_id Cloudflare zone ID.
* @return bool Whether purge was successful.
*/
public function purge_cache(string $zone_id): bool {
return $this->zones->cachePurgeEverything($zone_id);
}
}
Cron Integration
update_cloudflare.php syncs zone data and updates suma_sites.cf_zone_id for each managed site.
Envato
Purpose
Verifies Envato marketplace licenses for premium themes and plugins.
Usage
namespace Suma;
class Envato {
private string $token;
public function __construct() {
$this->token = get_option('suma_envato_token');
}
/**
* Verifies a purchase code against the Envato API.
*
* @param string $purchase_code The Envato purchase code.
* @return array|false Purchase details or false if invalid.
*/
public function verify_license(string $purchase_code): array|false {
$response = wp_remote_get(
"https://api.envato.com/v3/market/author/sale?code={$purchase_code}",
[
'headers' => [
'Authorization' => "Bearer {$this->token}",
],
]
);
if (wp_remote_retrieve_response_code($response) !== 200) {
return false;
}
return json_decode(wp_remote_retrieve_body($response), true);
}
}
Reports
- Unused Envato — Purchase codes not assigned to any site
- All Envato — Complete inventory of Envato purchases
UptimeRobot
Purpose
Monitors website uptime and availability.
Integration
// cron/uptime-robot.php
$api_key = get_option('suma_uptimerobot_key');
$response = wp_remote_post('https://api.uptimerobot.com/v2/getMonitors', [
'body' => [
'api_key' => $api_key,
'format' => 'json',
'logs' => 1,
],
]);
$monitors = json_decode(wp_remote_retrieve_body($response), true);
foreach ($monitors['monitors'] as $monitor) {
// Match monitor to suma_sites by URL
// Update suma_sites.uptime field
}
Status Values
| Status | Meaning |
|---|---|
| 0 | Paused |
| 1 | Not checked yet |
| 2 | Up |
| 8 | Seems down |
| 9 | Down |
WP Engine API
Purpose
Syncs hosting environment data (PHP versions, domains, install details).
Configuration
| Setting | Value |
|---|---|
| API Version | v0 (legacy) |
| Authentication | API credentials (username + password) |
| Base URL | https://api.wpengineapi.com/v1/ |
Usage
// cron/update-servers.php
$credentials = base64_encode(
get_option('suma_wpengine_user') . ':' . get_option('suma_wpengine_pass')
);
$response = wp_remote_get('https://api.wpengineapi.com/v1/installs', [
'headers' => [
'Authorization' => "Basic {$credentials}",
],
]);
$installs = json_decode(wp_remote_retrieve_body($response), true);
foreach ($installs['results'] as $install) {
// Update suma_wpengine table
// Fields: name, cname, php, environment, primary_domain, is_multisite
}
Bitbucket
Purpose
Git repository tracking and developer commit activity monitoring.
Integration Points
| Feature | Description |
|---|---|
| Commit tracking | daily-git-reports.php queries recent commits |
| Repository listing | suma_repos table stores all repos |
| Developer activity | suma_git_status tracks per-developer metrics |
| Webhook IPs | Whitelist for incoming deployment webhooks |
Webhook IP Whitelist
Bitbucket Cloud webhook IPs must be allowed through firewalls:
34.198.203.127/32
34.198.178.64/32
34.198.32.85/32
104.192.136.0/21
SSL Certificate Verification
Purpose
Checks SSL certificate validity and expiration for all managed sites.
Library
Uses spatie/ssl-certificate ^1.22.1:
use Spatie\SslCertificate\SslCertificate;
/**
* Checks SSL certificate status for a site URL.
*
* @param string $url The site URL to check.
* @return array Certificate status data.
*/
function check_ssl(string $url): array {
try {
$certificate = SslCertificate::createForHostName(
parse_url($url, PHP_URL_HOST)
);
return [
'valid' => $certificate->isValid(),
'issuer' => $certificate->getIssuer(),
'expires' => $certificate->expirationDate()->format('Y-m-d'),
'days_remaining' => $certificate->daysUntilExpirationDate(),
];
} catch (Exception $exception) {
return [
'valid' => false,
'error' => $exception->getMessage(),
];
}
}
Summary of API Credentials Needed
| Service | Option Key | Where to Get |
|---|---|---|
| Asana | suma_asana_token | Asana Developer Console |
| Service account JSON file | Google Cloud Console | |
| Cloudflare | suma_cloudflare_token | Cloudflare Dashboard → API Tokens |
| Envato | suma_envato_token | Envato Account → API |
| UptimeRobot | suma_uptimerobot_key | UptimeRobot Settings |
| WP Engine | suma_wpengine_user / suma_wpengine_pass | WP Engine Portal |
| Bitbucket | OAuth configured in Git class | Bitbucket App Passwords |
| Harvest | harvest_access_token | Harvest Developers → Personal Access Tokens |
| Gemini | suma-gemini_api_key | Google AI Studio |
| Pinecone | suma_pinecone_api_key | Pinecone Dashboard |