| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Http\Client\Common; |
| 6 |
|
| 7 |
use Http\Client\Exception; |
| 8 |
use Http\Client\HttpClient; |
| 9 |
use Psr\Http\Message\ResponseInterface; |
| 10 |
use Psr\Http\Message\StreamInterface; |
| 11 |
use Psr\Http\Message\UriInterface; |
| 12 |
|
| 13 |
/** |
| 14 |
* Convenience HTTP client that integrates the MessageFactory in order to send |
| 15 |
* requests in the following form:. |
| 16 |
* |
| 17 |
* $client |
| 18 |
* ->get('/foo') |
| 19 |
* ->post('/bar') |
| 20 |
* ; |
| 21 |
* |
| 22 |
* The client also exposes the sendRequest methods of the wrapped HttpClient. |
| 23 |
* |
| 24 |
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com> |
| 25 |
* @author David Buchmann <mail@davidbu.ch> |
| 26 |
*/ |
| 27 |
interface HttpMethodsClientInterface extends HttpClient |
| 28 |
{ |
| 29 |
/** |
| 30 |
* Sends a GET request. |
| 31 |
* |
| 32 |
* @param string|UriInterface $uri |
| 33 |
* |
| 34 |
* @throws Exception |
| 35 |
*/ |
| 36 |
public function get($uri, array $headers = []): ResponseInterface; |
| 37 |
|
| 38 |
/** |
| 39 |
* Sends an HEAD request. |
| 40 |
* |
| 41 |
* @param string|UriInterface $uri |
| 42 |
* |
| 43 |
* @throws Exception |
| 44 |
*/ |
| 45 |
public function head($uri, array $headers = []): ResponseInterface; |
| 46 |
|
| 47 |
/** |
| 48 |
* Sends a TRACE request. |
| 49 |
* |
| 50 |
* @param string|UriInterface $uri |
| 51 |
* |
| 52 |
* @throws Exception |
| 53 |
*/ |
| 54 |
public function trace($uri, array $headers = []): ResponseInterface; |
| 55 |
|
| 56 |
/** |
| 57 |
* Sends a POST request. |
| 58 |
* |
| 59 |
* @param string|UriInterface $uri |
| 60 |
* @param string|StreamInterface|null $body |
| 61 |
* |
| 62 |
* @throws Exception |
| 63 |
*/ |
| 64 |
public function post($uri, array $headers = [], $body = null): ResponseInterface; |
| 65 |
|
| 66 |
/** |
| 67 |
* Sends a PUT request. |
| 68 |
* |
| 69 |
* @param string|UriInterface $uri |
| 70 |
* @param string|StreamInterface|null $body |
| 71 |
* |
| 72 |
* @throws Exception |
| 73 |
*/ |
| 74 |
public function put($uri, array $headers = [], $body = null): ResponseInterface; |
| 75 |
|
| 76 |
/** |
| 77 |
* Sends a PATCH request. |
| 78 |
* |
| 79 |
* @param string|UriInterface $uri |
| 80 |
* @param string|StreamInterface|null $body |
| 81 |
* |
| 82 |
* @throws Exception |
| 83 |
*/ |
| 84 |
public function patch($uri, array $headers = [], $body = null): ResponseInterface; |
| 85 |
|
| 86 |
/** |
| 87 |
* Sends a DELETE request. |
| 88 |
* |
| 89 |
* @param string|UriInterface $uri |
| 90 |
* @param string|StreamInterface|null $body |
| 91 |
* |
| 92 |
* @throws Exception |
| 93 |
*/ |
| 94 |
public function delete($uri, array $headers = [], $body = null): ResponseInterface; |
| 95 |
|
| 96 |
/** |
| 97 |
* Sends an OPTIONS request. |
| 98 |
* |
| 99 |
* @param string|UriInterface $uri |
| 100 |
* @param string|StreamInterface|null $body |
| 101 |
* |
| 102 |
* @throws Exception |
| 103 |
*/ |
| 104 |
public function options($uri, array $headers = [], $body = null): ResponseInterface; |
| 105 |
|
| 106 |
/** |
| 107 |
* Sends a request with any HTTP method. |
| 108 |
* |
| 109 |
* @param string $method HTTP method to use |
| 110 |
* @param string|UriInterface $uri |
| 111 |
* @param string|StreamInterface|null $body |
| 112 |
* |
| 113 |
* @throws Exception |
| 114 |
*/ |
| 115 |
public function send(string $method, $uri, array $headers = [], $body = null): ResponseInterface; |
| 116 |
} |
| 117 |
|