From de317675a8069b747cb253ba3e2b5dc394ca36ef Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sat, 18 Jul 2026 21:44:51 +0000
Subject: [PATCH] =Base Integrations mainly done - doing a test with setting up the Square integration to follow

---
 inc/integrations/_Base.php |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 58 insertions(+), 1 deletions(-)

diff --git a/inc/integrations/_Base.php b/inc/integrations/_Base.php
index 2d62970..80e71f8 100644
--- a/inc/integrations/_Base.php
+++ b/inc/integrations/_Base.php
@@ -30,6 +30,7 @@
 	 */
 	protected string $apiVersion;
 	protected Cache $cache;
+	protected ?string $cacheName = null;
 	//Use Trait "Requests" to set this
 	protected bool $hasRequests = false;
 	protected ?RateLimits $requestLimiter = null;
@@ -61,8 +62,36 @@
 	 * Usually used for default field values for syncable services
 	 */
 	public 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. Set by child classes' setContentTypes
+	 */
+	protected array $contentTypes = [];
 
 
 	/**
@@ -107,4 +136,32 @@
 		}
 		return jvbDashIcon($icon);
 	}
+
+	protected function initializeRateLimiters():void
+	{
+		$key = $this->service_name;
+		if (!is_null($this->userID)) {
+			$key .= '_'.$this->userID;
+		}
+
+		if ($this->hasRequests && !isset($this->requestLimiter) && !is_null($this->oauthLimiter)) {
+			$this->requestLimiter = new RateLimits($key);
+		}
+		if ($this->hasOAuth && !isset($this->oauthLimiter) && !is_null($this->oauthLimiter)) {
+			$key .= '_oauth';
+			$this->oauthLimiter = new RateLimits($key, ['s' => 1,'m' => 10, 'h' => 100]);
+		}
+	}
+
+	public function response(bool $success, string $message, array $data = []):array
+	{
+		$response = [
+			'success'	=> $success,
+			'message'	=> $message
+		];
+		if (!empty($data)) {
+			$response['data'] = $data;
+		}
+		return $response;
+	}
 }

--
Gitblit v1.10.0