Fix class name

This commit is contained in:
Oliver Davies 2020-05-30 03:08:48 +01:00
parent 352ef9d14f
commit 3b8b8995f4
2 changed files with 5 additions and 5 deletions

View file

@ -0,0 +1,47 @@
<?php
namespace Opdavies\Glassboxx\Request;
use Opdavies\Glassboxx\Config;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Contracts\HttpClient\HttpClientInterface;
final class AuthTokenRequest extends AbstractRequest
{
public const ENDPOINT = '/integration/admin/token';
/** @var Config */
private $config;
/** @var HttpClient */
private $client;
public function __construct(HttpClientInterface $client)
{
$this->client = $client;
}
public function withConfig(Config $config): self
{
$this->config = $config;
return $this;
}
public function getToken(): string
{
$response = $this->client
->request(
'POST',
self::BASE_URL.self::ENDPOINT,
[
'query' => [
'password' => $this->config->getPassword(),
'username' => $this->config->getUsername(),
],
]
);
return json_decode($response->getContent());
}
}