forked from apoloz/alfa-bank-sdk
first commit
This commit is contained in:
46
src/Requests/Auth/GetTokenRequest.php
Normal file
46
src/Requests/Auth/GetTokenRequest.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Requests\Auth;
|
||||
|
||||
use Gemini\AlfaBank\Data\Auth\TokenData;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasFormBody;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
|
||||
class GetTokenRequest extends Request implements HasBody
|
||||
{
|
||||
use HasFormBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected string $clientId,
|
||||
protected string $clientSecret,
|
||||
protected string $code,
|
||||
protected string $redirectUri,
|
||||
protected string $grantType = 'authorization_code'
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '/oidc/token';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return [
|
||||
'grant_type' => $this->grantType,
|
||||
'client_id' => $this->clientId,
|
||||
'client_secret' => $this->clientSecret,
|
||||
'code' => $this->code,
|
||||
'redirect_uri' => $this->redirectUri,
|
||||
];
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): TokenData
|
||||
{
|
||||
return TokenData::from($response->json());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user