diff --git a/README.md b/README.md new file mode 100644 index 0000000..6ca048b --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Hurtom Toloka PHP-API library + +This library uses web-scrapping method to work with web resource. \ No newline at end of file diff --git a/src/Client.php b/src/Client.php index ee9197a..32d940d 100644 --- a/src/Client.php +++ b/src/Client.php @@ -6,7 +6,7 @@ use Psr\Http\Client\ClientInterface as HttpClientInterface; use Psr\Log\LoggerInterface; use Psr\SimpleCache\CacheInterface; -class Client { +class Client implements ClientInterface { /** * Hurtom Toloka base url. @@ -15,6 +15,11 @@ class Client { */ protected string $base_url; + /** + * Http client. + * + * @var HttpClientInterface + */ protected HttpClientInterface $httpClient; /** @@ -49,6 +54,33 @@ class Client { $this->logger = $logger; } + /** + * {@inheritDoc} + */ + public function login(string $login, string $password): void { + // TODO: Implement login() method. + } + + /** + * {@inheritDoc} + */ + public function isLoggedIn(): bool { + // TODO: Implement isLoggedIn() method. + } + + /** + * {@inheritDoc} + */ + public function logout(): void { + // TODO: Implement logout() method. + } + + /** + * {@inheritDoc} + */ + public function getTopic(int $id): TopicInterface { + // TODO: Implement getTopic() method. + } } diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 9e6bbc2..7b383f8 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -8,13 +8,39 @@ interface ClientInterface { * Login using credentials. * * @param string $login - * + * User login. * @param string $password + * User password. * - * @throws InvalidAuthCredentials - * - * @return void + * @throws \Toloka\PhpApi\Exception\Auth\InvalidAuthCredentials + * @throws \Toloka\PhpApi\Exception\Auth\TooManyLoginAttempts + * @throws \Psr\Http\Client\ClientExceptionInterface */ public function login(string $login, string $password): void; + /** + * Check if user logged in. + * + * @return bool + */ + public function isLoggedIn(): bool; + + /** + * Perform user's logout. + * + * @throws \Psr\Http\Client\ClientExceptionInterface + */ + public function logout(): void; + + /** + * Get topic by ID. + * + * @param int $id + * Integer serial number of topic. + * + * @return TopicInterface + * Object with populated topic data. + */ + public function getTopic(int $id): TopicInterface; + } diff --git a/src/Exception/Auth/InvalidAuthCredentials.php b/src/Exception/Auth/InvalidAuthCredentials.php new file mode 100644 index 0000000..43242e1 --- /dev/null +++ b/src/Exception/Auth/InvalidAuthCredentials.php @@ -0,0 +1,11 @@ +