forked from apoloz/alfa-bank-sdk
refactor(core): enhance SDK structure and documentation
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -1,15 +1,29 @@
|
||||
<?php
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for OpenID Connect UserInfo claims.
|
||||
// RESPONSIBILITY: To hold and type-safely represent details about the authenticated end-user.
|
||||
// INPUTS: Raw JSON object (typically from a JWT payload) from the UserInfo endpoint.
|
||||
// OUTPUTS: A structured object containing user claims.
|
||||
// LINKS: Requests/Auth/UserInfo/GetUserInfoRequest.php
|
||||
*/
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Auth\UserInfo;
|
||||
|
||||
// <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 OpenID Connect UserInfo claims.">
|
||||
// <BELIEF_STATE "This DTO provides a clear, type-safe contract for handling user claims returned by the OIDC UserInfo endpoint, ensuring consistent access to user attributes.">
|
||||
class UserInfoData extends Data
|
||||
{
|
||||
// <SECTION name="constructor_properties" intent="Define the standard and extended properties (claims) for user information.">
|
||||
// <BELIEF_STATE "The constructor includes `sub` (subject identifier) as mandatory. Many other fields are optional and represent common OIDC claims like `name`, `email`, `birthdate`, `phone_number`, and `inn`. These claims provide rich detail about the end-user.">
|
||||
public function __construct(
|
||||
public string $sub,
|
||||
public ?string $iss = null,
|
||||
public ?string $aud = null,
|
||||
public ?string $iss = null, // Issuer
|
||||
public ?string $aud = null, // Audience
|
||||
public ?string $name = null,
|
||||
public ?string $given_name = null,
|
||||
public ?string $family_name = null,
|
||||
@@ -18,7 +32,8 @@ class UserInfoData extends Data
|
||||
public ?string $gender = null,
|
||||
public ?string $birthdate = null,
|
||||
public ?string $phone_number = null,
|
||||
public ?string $inn = null,
|
||||
public ?string $inn = null, // Individual Taxpayer Number (Russia)
|
||||
// Add more claims as needed based on the response
|
||||
) {}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user