// use Apoloz\AlfaBank\Data\Auth\TokenData; use Saloon\Contracts\Body\HasBody; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasFormBody; // //
// 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 = null, protected ?string $redirectUri = null, protected ?string $refreshToken = null, protected string $grantType = 'authorization_code' ) {} //
//
// public function resolveEndpoint(): string { return '/oidc/token'; } //
//
// protected function defaultBody(): array { $body = [ 'grant_type' => $this->grantType, 'client_id' => $this->clientId, 'client_secret' => $this->clientSecret, ]; if ($this->grantType === 'authorization_code') { $body['code'] = $this->code; $body['redirect_uri'] = $this->redirectUri; } if ($this->grantType === 'refresh_token') { $body['refresh_token'] = $this->refreshToken; } return $body; } //
//
// public function createDtoFromResponse(Response $response): TokenData { return TokenData::from($response->json()); } //
}