Files
kiri-core/http-handler/Client/IClient.php
T

192 lines
3.3 KiB
PHP
Raw Normal View History

2020-11-14 04:46:52 +08:00
<?php
2021-09-29 15:41:13 +08:00
namespace Http\Handler\Client;
2020-11-14 04:46:52 +08:00
2021-05-06 10:49:00 +08:00
use Closure;
2021-09-29 15:41:13 +08:00
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
2021-05-06 10:49:00 +08:00
2020-11-14 04:46:52 +08:00
interface IClient
{
2020-11-17 10:44:29 +08:00
/**
* @param string $path
* @param array $params
2021-09-29 15:41:13 +08:00
* @return ResponseInterface
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function get(string $path, array $params = []): ResponseInterface;
2020-11-17 10:44:29 +08:00
/**
* @param string $path
* @param array $params
2021-09-29 15:41:13 +08:00
* @return ResponseInterface
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function post(string $path, array $params = []): ResponseInterface;
2020-11-17 10:44:29 +08:00
/**
* @param string $path
* @param array $params
2021-09-29 15:41:13 +08:00
* @return ResponseInterface
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function delete(string $path, array $params = []): ResponseInterface;
2020-11-17 10:44:29 +08:00
/**
* @param string $path
* @param array $params
2021-09-29 15:41:13 +08:00
* @return ResponseInterface
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function options(string $path, array $params = []): ResponseInterface;
2020-11-17 10:44:29 +08:00
/**
* @param string $path
* @param array $params
2021-09-29 15:41:13 +08:00
* @return ResponseInterface
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function upload(string $path, array $params = []): ResponseInterface;
2020-11-17 10:44:29 +08:00
/**
* @param string $path
* @param array $params
2021-09-29 15:41:13 +08:00
* @return ResponseInterface
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function put(string $path, array $params = []): ResponseInterface;
2020-11-17 10:44:29 +08:00
/**
* @param string $path
* @param array $params
2021-09-29 15:41:13 +08:00
* @return ResponseInterface
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function head(string $path, array $params = []): ResponseInterface;
2020-11-17 10:44:29 +08:00
/**
* @param string $method
* @param string $path
* @param array $params
2021-09-29 15:41:13 +08:00
* @return ResponseInterface
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function request(string $method, string $path, array $params = []): ResponseInterface;
2020-11-17 10:44:29 +08:00
/**
* @param string $host
2021-09-29 15:41:13 +08:00
* @return static
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function withHost(string $host): static;
2020-11-17 10:44:29 +08:00
/**
* @param array $header
2021-09-29 15:41:13 +08:00
* @return static
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function withHeader(array $header): static;
2020-11-17 10:44:29 +08:00
/**
* @param array $header
2021-09-29 15:41:13 +08:00
* @return static
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function withHeaders(array $header): static;
2020-11-17 10:44:29 +08:00
/**
* @param string $key
* @param string $value
2021-09-29 15:41:13 +08:00
* @return static
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function withAddedHeader(string $key, string $value): static;
2020-11-17 10:44:29 +08:00
/**
* @param int $value
2021-09-29 15:41:13 +08:00
* @return static
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function withTimeout(int $value): static;
2020-11-17 10:44:29 +08:00
/**
2021-05-06 10:49:00 +08:00
* @param Closure|null $value
2021-09-29 15:41:13 +08:00
* @return static
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function withCallback(?Closure $value): static;
2020-11-17 10:44:29 +08:00
/**
* @param string $value
2021-05-06 10:49:00 +08:00
* @return static
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function withMethod(string $value): static;
2020-11-17 10:44:29 +08:00
/**
* @param bool $isSSL
2021-09-29 15:41:13 +08:00
* @return static
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function withIsSSL(bool $isSSL): static;
2020-11-17 10:44:29 +08:00
/**
* @param string $agent
2021-09-29 15:41:13 +08:00
* @return static
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function withAgent(string $agent): static;
2020-11-17 10:44:29 +08:00
/**
* @param string $ssl_cert_file
2021-09-29 15:41:13 +08:00
* @return static
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function withSslCertFile(string $ssl_cert_file): static;
2020-11-17 10:44:29 +08:00
/**
* @param string $ssl_key_file
2021-09-29 15:41:13 +08:00
* @return static
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function withSslKeyFile(string $ssl_key_file): static;
2020-11-17 10:44:29 +08:00
/**
* @param string $ssl_key_file
2021-09-29 15:41:13 +08:00
* @return static
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function withCa(string $ssl_key_file): static;
2020-11-17 10:44:29 +08:00
/**
* @param int $port
2021-09-29 15:41:13 +08:00
* @return static
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function withPort(int $port): static;
2020-11-17 10:44:29 +08:00
/**
2021-09-29 15:41:13 +08:00
* @param string|StreamInterface $data
* @return static
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function withBody(string|StreamInterface $data): static;
2020-11-17 10:44:29 +08:00
/**
* @param int $connect_timeout
2021-09-29 15:41:13 +08:00
* @return static
2020-11-17 10:44:29 +08:00
*/
2021-09-29 15:41:13 +08:00
public function withConnectTimeout(int $connect_timeout): static;
2020-11-17 10:44:29 +08:00
2020-11-18 14:33:59 +08:00
/**
* @param string $contentType
2021-09-29 15:41:13 +08:00
* @return static
2020-11-18 14:33:59 +08:00
*/
2021-09-29 15:41:13 +08:00
public function withContentType(string $contentType): static;
2020-11-17 10:44:29 +08:00
}