From ccf5e61a075c35d24befc175994b5cb8957ca322 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 26 Aug 2026 21:45:53 +0000
Subject: [PATCH] =Extra JVB() calls replaced, minor tweaks

---
 inc/integrations/_Base.php |   86 +++++++++++++++++++++++++++++++++++++-----
 1 files changed, 75 insertions(+), 11 deletions(-)

diff --git a/inc/integrations/_Base.php b/inc/integrations/_Base.php
index 2d62970..cc61055 100644
--- a/inc/integrations/_Base.php
+++ b/inc/integrations/_Base.php
@@ -2,6 +2,7 @@
 namespace JVBase\integrations;
 
 use JVBase\managers\Cache;
+use JVBase\managers\Errors;
 use JVBase\managers\IconsManager;
 
 if (!defined('ABSPATH')) {
@@ -30,14 +31,8 @@
 	 */
 	protected string $apiVersion;
 	protected Cache $cache;
-	//Use Trait "Requests" to set this
-	protected bool $hasRequests = false;
-	protected ?RateLimits $requestLimiter = null;
-	//Use Trait "OAuth" to set this
-	protected ?RateLimits $oauthLimiter = null;
-	protected bool $hasOAuth = false;
-	//Use trait "Webhooks" to set this true
-	protected bool $hasWebhooks = false;
+	protected ?string $cacheName = null;
+
 
 	/**
 	 * @var array Each item in the array becomes a li element in the ordered list of instructions
@@ -60,9 +55,39 @@
 	 * @var bool Flag to indicate there are extra options that warrant a dedicated options page for this service
 	 * Usually used for default field values for syncable services
 	 */
-	public bool $hasExtraOptions = false;
+	public static bool $hasExtraOptions = false;
+	public bool $hasBatchCreate = false;
+	public bool $hasBatchUpdate = false;
+	public bool $hasBatchDelete = false;
+	public bool $canCreateOnUpdate = false;
+	/**
+	 * Post Syncing Capabilities
+	 * Define what sync operations this integration supports
+	 */
+	protected array $canSync = [
+		'initial' => false,    // Can share new posts to the service
+		'update' => false,     // Can update already-shared posts
+		'delete' => false,     // Can remove posts from the service
+	];
 
+	/**
+	 * @var array // Post types that can be synced (e.g., ['artwork', 'tattoo']): usually built by Registrar.php if the integration name exists as a key in [ 'integrations' => []]
+	 */
+	protected array $syncPostTypes = [];
+	/**
+	 * @var array Taxonomies that can be synced (e.g., ['category', 'section']): usually built by Registrar.php if the integration name exists as a key in [ 'integrations' => []]
+	 */
+	protected array $syncTaxonomies = [];
+	/**
+	 * @var array User roles that can be synced (e.g., ['customer']): usually built by Registrar.php if the integration name exists as a key in [ 'integrations' => []]
+	 */
+	protected array $syncUsers = [];
+	/**
+	 * @var array Integration's specific content types. An array of [ TYPE => [$fields] ] Set by child classes' setContentTypes
+	 */
+	protected array $contentTypes = [];
 
+	protected array $credentials;
 
 
 	/**
@@ -75,13 +100,16 @@
 
 	public function loadCredentials():array
 	{
-		return Auth::getInstance()->getCredentials($this->service_name, $this->userID);
+		if (!isset($this->credentials)) {
+			$this->credentials = Auth::getInstance()->getCredentials($this->service_name, $this->userID);
+		}
+		return $this->credentials;
 	}
 
 	protected function logError(string $method, string $message, array $context = []):void
 	{
 		$context['service'] = $this->service_name;
-		JVB()->error()->log('['.self::class.']'.$method, $message, $context);
+		Errors::getInstance()->log('['.self::class.']'.$method, $message, $context);
 	}
 
 	protected function getReturnURL():string
@@ -107,4 +135,40 @@
 		}
 		return jvbDashIcon($icon);
 	}
+
+	protected function initializeRateLimiters():void
+	{
+		$key = $this->service_name;
+		if (!is_null($this->userID)) {
+			$key .= '_'.$this->userID;
+		}
+		if (method_exists($this, 'initializeRequestLimiter')) {
+			$this->initializeRequestLimiter();
+		}
+		if (method_exists($this, 'initializeOAuthRateLimiter')) {
+			$this->initializeOAuthRateLimiter();
+		}
+	}
+
+	public function response(bool $success, string $message, array $data = []):array
+	{
+		$response = [
+			'success'	=> $success,
+			'message'	=> $message
+		];
+		if (!empty($data)) {
+			$response['data'] = $data;
+		}
+		return $response;
+	}
+
+	public function getAllowedContent():array
+	{
+		return array_keys($this->contentTypes);
+	}
+
+	public function getServiceName():string
+	{
+		return $this->service_name;
+	}
 }

--
Gitblit v1.10.0