2020-05-30 02:29:54 +01:00
|
|
|
<?php
|
|
|
|
|
2020-05-30 03:18:43 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-05-30 02:29:54 +01:00
|
|
|
namespace Opdavies\Glassboxx\Request;
|
|
|
|
|
2020-06-05 21:37:17 +01:00
|
|
|
use RuntimeException;
|
|
|
|
|
2020-05-30 16:45:40 +01:00
|
|
|
final class AuthTokenRequest extends AbstractRequest implements AuthTokenRequestInterface
|
2020-05-30 02:29:54 +01:00
|
|
|
{
|
|
|
|
public function getToken(): string
|
|
|
|
{
|
2020-06-05 21:37:17 +01:00
|
|
|
if (!$this->config) {
|
|
|
|
throw new RuntimeException('There is no config');
|
|
|
|
}
|
|
|
|
|
2020-05-30 16:45:40 +01:00
|
|
|
$response = $this->client->request(
|
|
|
|
'POST',
|
2020-06-05 20:59:12 +01:00
|
|
|
self::ENDPOINT,
|
2020-05-30 16:45:40 +01:00
|
|
|
[
|
|
|
|
'query' => [
|
|
|
|
'password' => $this->config->getPassword(),
|
|
|
|
'username' => $this->config->getUsername(),
|
|
|
|
],
|
|
|
|
]
|
|
|
|
);
|
2020-05-30 02:29:54 +01:00
|
|
|
|
|
|
|
return json_decode($response->getContent());
|
|
|
|
}
|
|
|
|
}
|