The HttpClient class handles all low-level HTTP communication. It is used internally by all resource classes and the OAuthHelper. You do not normally need to use it directly, but it is available if you need to make raw requests.
Authentication #
The HttpClient sends the API key in the X-API-Key request header on every request. All requests are sent to {baseUrl}/wp-json/dmsi-api/v1/{path}.
Automatic Retry on Rate Limiting #
When a 429 Too Many Requests response is received, the HttpClient automatically retries the request up to MAX_RETRIES = 3 times using exponential backoff. If the response includes a Retry-After header, that value is used as the delay. Otherwise, the backoff delay doubles with each attempt.
Methods #
$http->get(string $path, array $params = []): array
$http->post(string $path, array $body = []): array
$http->put(string $path, array $body = []): array
$http->delete(string $path): array
All methods return the decoded JSON response as an associative array. On non-2xx responses, an appropriate exception is thrown (see Doc 7: Exception Classes).
