From a8ff85042ffbfe94b678fd818c02deb613bfd116 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 07 Aug 2026 20:42:54 +0000
Subject: [PATCH] =Continuing on with Integrations setup. Working on PostMark now
---
inc/integrations/Requests.php | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/inc/integrations/Requests.php b/inc/integrations/Requests.php
index ad9ebfc..633c6af 100644
--- a/inc/integrations/Requests.php
+++ b/inc/integrations/Requests.php
@@ -7,12 +7,12 @@
trait Requests
{
- protected bool $hasRequests = true;
/**
* Child classes must set this (e.g. 'https://api.example.com/v1/')
*/
protected ?string $baseUrl = null;
protected int $ttl = 300; //5 minutes default
+ protected ?RateLimits $requestLimiter = null;
/**
* Child classes define their auth headers (Bearer token, API key, etc.)
@@ -25,6 +25,15 @@
*/
abstract protected function handleResponse(array|\WP_Error $response, string $method, string $endpoint): array;
+ protected function initializeRequestLimiter():void
+ {
+ $key = $this->service_name;
+ if (!is_null($this->userID)) {
+ $key .= '_'.$this->userID;
+ }
+ $this->requestLimiter = new RateLimits($key);
+ }
+
public function getRequest(string $endpoint, array $data = [], bool $force = false, ?int $ttl = null): array
{
$key = [$this->service_name, $this->userID, $endpoint, $data];
--
Gitblit v1.10.0