refactor(core): enhance SDK structure and documentation
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -1,14 +1,28 @@
|
||||
<?php
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the request payload when creating a new requisite.
|
||||
// RESPONSIBILITY: To hold and validate all necessary information for registering a new payment requisite for a beneficiary.
|
||||
// INPUTS: Payment type, digest signatures, and various optional requisite details (PAN, account number, phone, etc.).
|
||||
// OUTPUTS: A structured, type-safe object for the `AddRequisiteRequest` payload.
|
||||
// LINKS: Requests/NominalAccounts/Beneficiaries/Requisites/AddRequisiteRequest.php
|
||||
*/
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\Requisites;
|
||||
|
||||
// <SECTION name="module_imports" intent="Import necessary DTOs and Spatie Laravel Data components.">
|
||||
// <BELIEF_STATE "This DTO requires `DigestSignatureData` as a collection for security, utilizing `DataCollectionOf` for type safety.">
|
||||
use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DigestSignatureData;
|
||||
use Spatie\LaravelData\Attributes\DataCollectionOf;
|
||||
use Spatie\LaravelData\Data;
|
||||
use Spatie\LaravelData\DataCollection;
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define a DTO for creating a new requisite.">
|
||||
// <BELIEF_STATE "This DTO ensures the request payload for creating a requisite is strictly typed and complete, preventing malformed requests for a critical financial operation.">
|
||||
class CreateRequisiteRequestData extends Data
|
||||
{
|
||||
// <SECTION name="constructor_properties" intent="Define all properties for the requisite creation request.">
|
||||
// <BELIEF_STATE "The constructor includes mandatory fields like `type` and `digestSignatures`. Optional fields cover various payment methods (`pan`, `phoneNumber`, `accountNumber`) and identifiers (`bankId`, `bik`, `name`, `inn`, `kpp`, `beneficiaryId`, `isMain`).">
|
||||
public function __construct(
|
||||
public string $type,
|
||||
#[DataCollectionOf(DigestSignatureData::class)]
|
||||
@@ -24,4 +38,5 @@ class CreateRequisiteRequestData extends Data
|
||||
public ?string $kpp = null,
|
||||
public ?bool $isMain = null,
|
||||
) {}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
@@ -1,16 +1,30 @@
|
||||
<?php
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a single payment requisite.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the details of a registered payment method (e.g., bank account, card, phone).
|
||||
// INPUTS: Raw JSON object from the API response.
|
||||
// OUTPUTS: A structured object containing requisite details.
|
||||
// LINKS: Requests/NominalAccounts/Beneficiaries/Requisites/GetRequisitesRequest.php
|
||||
*/
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\Requisites;
|
||||
|
||||
// <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 a single payment requisite.">
|
||||
// <BELIEF_STATE "This DTO provides a clear, type-safe contract for requisite data, crucial for managing payment methods reliably.">
|
||||
class RequisiteData extends Data
|
||||
{
|
||||
// <SECTION name="constructor_properties" intent="Define the properties of a payment requisite.">
|
||||
// <BELIEF_STATE "The constructor includes a mix of mandatory (`type`, `isMain`, `isActive`) and optional fields (`id`, `pan`, `phoneNumber`, `accountNumber`, `bankId`, `bik`, `name`, `inn`, `kpp`). These fields describe the payment method and its current status.">
|
||||
public function __construct(
|
||||
public ?string $id = null,
|
||||
public string $type,
|
||||
public bool $isMain,
|
||||
public bool $isActive,
|
||||
public ?string $id = null, // Requisite ID might be generated on creation
|
||||
public ?string $pan = null,
|
||||
public ?string $phoneNumber = null,
|
||||
public ?string $bankId = null,
|
||||
@@ -20,4 +34,5 @@ class RequisiteData extends Data
|
||||
public ?string $inn = null,
|
||||
public ?string $kpp = null,
|
||||
) {}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
@@ -1,19 +1,33 @@
|
||||
<?php
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the request payload when updating an existing requisite.
|
||||
// RESPONSIBILITY: To hold and validate necessary information for modifying a payment requisite.
|
||||
// INPUTS: Digest signatures, and various optional requisite details (PAN, account number, phone, etc.).
|
||||
// OUTPUTS: A structured, type-safe object for the `UpdateRequisiteRequest` payload.
|
||||
// LINKS: Requests/NominalAccounts/Beneficiaries/Requisites/UpdateRequisiteRequest.php
|
||||
*/
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\Requisites;
|
||||
|
||||
// <SECTION name="module_imports" intent="Import necessary DTOs and Spatie Laravel Data components.">
|
||||
// <BELIEF_STATE "This DTO requires `DigestSignatureData` as a collection for security, utilizing `DataCollectionOf` for type safety.">
|
||||
use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DigestSignatureData;
|
||||
use Spatie\LaravelData\Attributes\DataCollectionOf;
|
||||
use Spatie\LaravelData\Data;
|
||||
use Spatie\LaravelData\DataCollection;
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define a DTO for updating an existing requisite.">
|
||||
// <BELIEF_STATE "This DTO ensures the request payload for updating a requisite is strictly typed and complete, supporting partial updates through nullable fields.">
|
||||
class UpdateRequisiteRequestData extends Data
|
||||
{
|
||||
// <SECTION name="constructor_properties" intent="Define all properties for the requisite update request.">
|
||||
// <BELIEF_STATE "The constructor includes mandatory `digestSignatures` for security. Optional fields allow for specific updates to `pan`, `keyId`, `phoneNumber`, `bankId`, `accountNumber`, `bik`, `isMain` status, and `isActive` status. The flexibility with nullable fields allows partial updates.">
|
||||
public function __construct(
|
||||
#[DataCollectionOf(DigestSignatureData::class)]
|
||||
public DataCollection $digestSignatures,
|
||||
public ?string $pan = null,
|
||||
public ?string $keyId = null,
|
||||
public ?string $keyId = null, // Specific identifier for some requisite types
|
||||
public ?string $phoneNumber = null,
|
||||
public ?string $bankId = null,
|
||||
public ?string $accountNumber = null,
|
||||
@@ -21,4 +35,5 @@ class UpdateRequisiteRequestData extends Data
|
||||
public ?bool $isMain = null,
|
||||
public ?bool $isActive = null,
|
||||
) {}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user