Initialised composer, started prototyping.
commit
4bfc4ccdaf
|
@ -0,0 +1,3 @@
|
|||
.idea
|
||||
vendor/
|
||||
composer.lock
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"name": "toloka/php-api",
|
||||
"description": "PHP library to integrate with Hurtom Toloka using web scrapping.",
|
||||
"type": "library",
|
||||
"homepage": "http://git.devbones.com/Toloka/php-api",
|
||||
"require": {
|
||||
"php": ">=7.4",
|
||||
"psr/simple-cache": "^3.0",
|
||||
"psr/log": "^3.0",
|
||||
"psr/http-client": "^1.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Toloka\\PhpApi\\": "src/"
|
||||
}
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "conky",
|
||||
"email": "bogdan@devbones.com"
|
||||
}
|
||||
],
|
||||
"require-dev": {
|
||||
"guzzlehttp/guzzle": "^7.5"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace Toloka\PhpApi;
|
||||
|
||||
use Psr\Http\Client\ClientInterface as HttpClientInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
class Client {
|
||||
|
||||
/**
|
||||
* Hurtom Toloka base url.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected string $base_url;
|
||||
|
||||
protected HttpClientInterface $httpClient;
|
||||
|
||||
/**
|
||||
* Cache bin.
|
||||
*
|
||||
* @var CacheInterface
|
||||
*/
|
||||
protected CacheInterface $cache;
|
||||
|
||||
/**
|
||||
* Events logger.
|
||||
*
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
protected LoggerInterface $logger;
|
||||
|
||||
/**
|
||||
* Toloka client constructor.
|
||||
*
|
||||
* @param string $base_url
|
||||
* @param CacheInterface|NULL $cache
|
||||
* @param LoggerInterface|NULL $logger
|
||||
*/
|
||||
public function __construct(
|
||||
string $base_url = 'https://toloka.to',
|
||||
HttpClientInterface $httpClient,
|
||||
CacheInterface $cache,
|
||||
LoggerInterface $logger
|
||||
) {
|
||||
$this->httpClient = $httpClient;
|
||||
$this->cache = $cache;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Toloka\PhpApi;
|
||||
|
||||
interface ClientInterface {
|
||||
|
||||
/**
|
||||
* Login using credentials.
|
||||
*
|
||||
* @param string $login
|
||||
*
|
||||
* @param string $password
|
||||
*
|
||||
* @throws InvalidAuthCredentials
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function login(string $login, string $password): void;
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Toloka\PhpApi;
|
||||
|
||||
class InvalidAuthCredentials extends \Exception {
|
||||
|
||||
protected $message = 'Failed to login using given credentials.';
|
||||
|
||||
}
|
Loading…
Reference in New Issue