| | |
| | | <?php |
| | | namespace JVBase\integrations; |
| | | |
| | | use WP_Error; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | | } |
| | |
| | | * Child classes inspect the wp_remote_request response, |
| | | * decode it, and handle/log errors as needed |
| | | */ |
| | | abstract protected function handleResponse(array|\WP_Error $response, string $method, string $endpoint): array; |
| | | abstract protected function handleResponse(array|WP_Error $response, string $method, string $endpoint): array; |
| | | |
| | | protected function initializeRequestLimiter():void |
| | | { |
| | |
| | | return []; |
| | | } |
| | | if ($this->requestLimiter && !$this->awaitRateLimit($endpoint)) { |
| | | $error = new \WP_Error('rate_limit_exceeded', "Rate limit exceeded for {$endpoint}"); |
| | | $error = new WP_Error('rate_limit_exceeded', "Rate limit exceeded for {$endpoint}"); |
| | | return $this->handleResponse($error, $method, $endpoint); |
| | | } |
| | | |