Skip to main content

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

SettingValue
Libraryasana/asana ^0.10
Workspace ID93834251219403
Team ID101071044814588
AuthenticationPersonal 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

ServicePurpose
Google SheetsProject tracking spreadsheet auto-population
Google AnalyticsSite traffic data (UA and GA4)
Google Tag ManagerContainer 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 sheet
  • google-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

SettingValue
Librarycloudflare/sdk ^1.1.6
AuthenticationAPI 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

StatusMeaning
0Paused
1Not checked yet
2Up
8Seems down
9Down

WP Engine API

Purpose

Syncs hosting environment data (PHP versions, domains, install details).

Configuration

SettingValue
API Versionv0 (legacy)
AuthenticationAPI credentials (username + password)
Base URLhttps://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

FeatureDescription
Commit trackingdaily-git-reports.php queries recent commits
Repository listingsuma_repos table stores all repos
Developer activitysuma_git_status tracks per-developer metrics
Webhook IPsWhitelist 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

ServiceOption KeyWhere to Get
Asanasuma_asana_tokenAsana Developer Console
GoogleService account JSON fileGoogle Cloud Console
Cloudflaresuma_cloudflare_tokenCloudflare Dashboard → API Tokens
Envatosuma_envato_tokenEnvato Account → API
UptimeRobotsuma_uptimerobot_keyUptimeRobot Settings
WP Enginesuma_wpengine_user / suma_wpengine_passWP Engine Portal
BitbucketOAuth configured in Git classBitbucket App Passwords
Harvestharvest_access_tokenHarvest Developers → Personal Access Tokens
Geminisuma-gemini_api_keyGoogle AI Studio
Pineconesuma_pinecone_api_keyPinecone Dashboard