http_client_adapter
class http_client_adapter implements http_client_interface
| internal |
Modern HTTP Client wrapper using Guzzle.
Serves as the standard HTTP client for the entire MIDDAG ecosystem. Automatically handles Moodle's proxy settings and User-Agent rules.
Usage: $client = new http_client_adapter('https://api.example.com'); $data = $client->set_authorization_bearer($token)->get('/users');
Methods
Initializes the client with default Moodle settings (timeout, proxy, user-agent).
Sets a custom header for subsequent requests.
Sets the Authorization Bearer token header.
Sets the Content-Type header.
Performs a synchronous GET request.
Performs a synchronous POST request.
Performs a synchronous PUT request with JSON body.
Performs a synchronous PATCH request with JSON body.
Performs a synchronous DELETE request.
Details
at line 54
__construct(string $base_uri = '')
Initializes the client with default Moodle settings (timeout, proxy, user-agent).
at line 97
http_client_interface
set_header(string $key, string $value)
Sets a custom header for subsequent requests.
at line 111
http_client_interface
set_authorization_bearer(string $token)
Sets the Authorization Bearer token header.
at line 123
http_client_interface
set_content_type(string $content_type)
Sets the Content-Type header.
at line 136
mixed
get(string $uri, array $query = [])
Performs a synchronous GET request.
at line 150
mixed
post(string $uri, array $data = [], bool $as_json = true)
Performs a synchronous POST request.
at line 165
mixed
put(string $uri, array $data = [])
Performs a synchronous PUT request with JSON body.
at line 178
mixed
patch(string $uri, array $data = [])
Performs a synchronous PATCH request with JSON body.
at line 191
mixed
delete(string $uri, array $query = [])
Performs a synchronous DELETE request.