glassboxx-sdk-php/src/Request/AuthTokenRequest.php

31 lines
704 B
PHP
Raw Normal View History

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