35 lines
1.6 KiB
PHP
35 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
/*
|
|
// MODULE_CONTRACT: Defines the data structure for an OAuth 2.0 token response.
|
|
// RESPONSIBILITY: To hold and type-safely represent the access token, refresh token, ID token, expiry, and token type returned by the OAuth provider.
|
|
// INPUTS: Raw JSON object from the token endpoint response.
|
|
// OUTPUTS: A structured object containing token information.
|
|
// LINKS: Requests/Auth/GetTokenRequest.php
|
|
*/
|
|
|
|
namespace Apoloz\AlfaBank\Data\Auth;
|
|
|
|
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
|
|
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from JSON and provides other DTO benefits.">
|
|
use Spatie\LaravelData\Data;
|
|
|
|
// </SECTION>
|
|
|
|
// <SECTION name="class_definition" intent="Define a DTO for OAuth 2.0 token responses.">
|
|
// <BELIEF_STATE "This DTO provides a clear, type-safe contract for handling sensitive token data, ensuring consistency and preventing errors when accessing token properties.">
|
|
class TokenData extends Data
|
|
{
|
|
// <SECTION name="constructor_properties" intent="Define the properties of an OAuth token response.">
|
|
// <BELIEF_STATE "The constructor includes mandatory fields like `access_token`, `refresh_token`, `expires_in`, and `token_type` as per OAuth 2.0. The `id_token` is optional and specific to OpenID Connect.">
|
|
public function __construct(
|
|
public string $access_token,
|
|
public string $refresh_token,
|
|
public ?string $id_token, // Specific to OpenID Connect
|
|
public int $expires_in,
|
|
public string $token_type
|
|
) {}
|
|
// </SECTION>
|
|
}
|