| | |
| | | */ |
| | | protected string $apiVersion; |
| | | protected Cache $cache; |
| | | protected ?string $cacheName = null; |
| | | //Use Trait "Requests" to set this |
| | | protected bool $hasRequests = false; |
| | | protected ?RateLimits $requestLimiter = null; |
| | |
| | | * 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 = []; |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | 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; |
| | | } |
| | | } |