refactor(core): enhance SDK structure and documentation

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
2026-01-18 21:48:25 +03:00
parent 3da69c03e1
commit d214eecebe
378 changed files with 10514 additions and 496 deletions

View File

@@ -1,16 +1,30 @@
<?php
/*
// MODULE_CONTRACT: Defines the data structure for the request payload to perform an action on a deal contractor.
// RESPONSIBILITY: To hold and validate all necessary information for actions such as adding or managing contractors within a deal step.
// INPUTS: Action type, deal ID, step ID, beneficiary ID, signatures, and optional financial details.
// OUTPUTS: A structured, type-safe object for the `ManageContractorRequest` payload.
// LINKS: Requests/NominalAccounts/Deals/Steps/ManageContractorRequest.php
*/
namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals\Steps;
// <SECTION name="module_imports" intent="Import necessary DTOs and Spatie Laravel Data components for complex nested data structures.">
// <BELIEF_STATE "This DTO orchestrates several other DTOs and collections (`DigestSignatureData`, `ContractorAmountData`), requiring `DataCollectionOf` for typed arrays.">
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 performing an action on a deal contractor.">
// <BELIEF_STATE "This DTO provides a robust contract for managing contractors within deal steps. It ensures that critical financial and security-related data is strictly typed and correctly structured for actions like adding funds or changing status.">
class ContractorActionRequestData extends Data
{
// <SECTION name="constructor_properties" intent="Define all properties for the contractor action request.">
// <BELIEF_STATE "The constructor includes mandatory fields like `action`, `dealId`, `stepId`, `beneficiaryId`, and `digestSignatures`. Optional fields like `amount`, `purpose`, `amounts` (for detailed distribution), `keepOnNominalAccount`, and `requisiteId` provide flexibility for various contractor management scenarios.">
public function __construct(
public string $action,
public string $action, // e.g., ADD_AMOUNT, REMOVE_AMOUNT, SET_REQUISITE
public string $dealId,
public string $stepId,
public string $beneficiaryId,
@@ -19,8 +33,9 @@ class ContractorActionRequestData extends Data
public ?string $amount = null,
public ?string $purpose = null,
#[DataCollectionOf(ContractorAmountData::class)]
public ?DataCollection $amounts = null,
public ?DataCollection $amounts = null, // For detailed amount distribution
public ?bool $keepOnNominalAccount = null,
public ?string $requisiteId = null,
) {}
// </SECTION>
}

View File

@@ -1,13 +1,28 @@
<?php
/*
// MODULE_CONTRACT: Defines the data structure for a specific amount allocated to a contractor's wallet.
// RESPONSIBILITY: To hold and type-safely represent an amount designated for a particular wallet type (e.g., nominal, tax).
// INPUTS: Raw JSON object or internal input.
// OUTPUTS: A structured object containing amount and wallet type.
// LINKS: ContractorActionRequestData.php (uses this DTO)
*/
namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals\Steps;
// <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 an amount allocated to a contractor's wallet.">
// <BELIEF_STATE "This DTO provides a precise, type-safe contract for specifying how funds are distributed across different wallet types for a contractor within a deal step, ensuring granular control over financial flows.">
class ContractorAmountData extends Data
{
// <SECTION name="constructor_properties" intent="Define the properties of a contractor amount allocation.">
// <BELIEF_STATE "The constructor includes optional fields for `walletType` (e.g., 'NOMINAL', 'TAX') and the `amount` to be allocated. Both are optional to allow for flexible usage, potentially being part of a larger distribution scheme where these properties might be inferred or contextually dependent.">
public function __construct(
public ?string $walletType = null,
public ?string $amount = null,
) {}
// </SECTION>
}

View File

@@ -1,20 +1,35 @@
<?php
/*
// MODULE_CONTRACT: Defines the data structure for the request payload to perform an action on a deal step.
// RESPONSIBILITY: To hold and validate all necessary information for actions such as completing or canceling a step within a deal.
// INPUTS: Deal ID, action type, signatures, and optional step ID and description.
// OUTPUTS: A structured, type-safe object for the `ManageStepRequest` payload.
// LINKS: Requests/NominalAccounts/Deals/Steps/ManageStepRequest.php
*/
namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals\Steps;
// <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 performing an action on a deal step.">
// <BELIEF_STATE "This DTO provides a robust contract for managing the lifecycle of deal steps. It ensures that critical operational and security data is strictly typed and correctly structured for actions like completion or cancellation.">
class StepActionRequestData extends Data
{
// <SECTION name="constructor_properties" intent="Define all properties for the step action request.">
// <BELIEF_STATE "The constructor includes mandatory fields like `dealId`, `action` (e.g., 'COMPLETE', 'CANCEL'), and `digestSignatures`. Optional fields like `stepId` (if targeting a specific step within the deal) and `description` provide flexibility and context for the action.">
public function __construct(
public string $dealId,
public string $action,
public string $action, // e.g., COMPLETE, CANCEL
#[DataCollectionOf(DigestSignatureData::class)]
public DataCollection $digestSignatures,
public ?string $stepId = null,
public ?string $description = null,
) {}
// </SECTION>
}

View File

@@ -1,11 +1,25 @@
<?php
/*
// MODULE_CONTRACT: Defines the data structure for the response of a step action request within a deal.
// RESPONSIBILITY: To hold and type-safely represent the outcome and status of an action performed on a deal step.
// INPUTS: Raw JSON object from the API response.
// OUTPUTS: A structured object containing step action status information.
// LINKS: Requests/NominalAccounts/Deals/Steps/ManageStepRequest.php
*/
namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals\Steps;
// <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 the response of a step action request.">
// <BELIEF_STATE "This DTO provides a clear, type-safe contract for tracking the status of actions performed on deal steps, which can be asynchronous operations.">
class StepActionResponseData extends Data
{
// <SECTION name="constructor_properties" intent="Define the properties of a step action response.">
// <BELIEF_STATE "The constructor includes key identifiers such as `dealId`, `stepId`, `stepNumber`, and `requestId`. The `status` and `description` provide details about the action's outcome. All fields are optional to accommodate various response scenarios.">
public function __construct(
public ?string $dealId = null,
public ?string $stepId = null,
@@ -14,4 +28,5 @@ class StepActionResponseData extends Data
public ?string $status = null,
public ?string $requestId = null,
) {}
// </SECTION>
}

View File

@@ -1,13 +1,27 @@
<?php
/*
// MODULE_CONTRACT: Defines the data structure for a contractor associated with a deal step.
// RESPONSIBILITY: To hold and type-safely represent details of a beneficiary acting as a contractor within a specific deal step.
// INPUTS: Raw JSON object from the API response.
// OUTPUTS: A structured object containing contractor details for a deal step.
// LINKS: Requests/NominalAccounts/Deals/Steps/GetStepContractorsRequest.php
*/
namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals\Steps;
// <SECTION name="module_imports" intent="Import necessary DTOs and Spatie Laravel Data components.">
// <BELIEF_STATE "This DTO uses `ContractorAmountData` within a collection, requiring `DataCollectionOf` for type safety.">
use Spatie\LaravelData\Attributes\DataCollectionOf;
use Spatie\LaravelData\Data;
use Spatie\LaravelData\DataCollection;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for a contractor in a deal step.">
// <BELIEF_STATE "This DTO provides a clear, type-safe contract for contractor details, including their role, associated amounts, and other relevant information within the context of a deal step.">
class StepContractorData extends Data
{
// <SECTION name="constructor_properties" intent="Define the properties of a step contractor.">
// <BELIEF_STATE "The constructor includes the `beneficiaryId`, `role` (e.g., 'DEBTOR', 'CREDITOR'), `amount`, `purpose`, `requisiteId`, and `keepOnNominalAccount` flag. The `amounts` property, if present, is a collection of `ContractorAmountData` for detailed amount distribution.">
public function __construct(
public ?string $beneficiaryId = null,
public ?string $role = null,
@@ -18,4 +32,5 @@ class StepContractorData extends Data
#[DataCollectionOf(ContractorAmountData::class)]
public ?DataCollection $amounts = null,
) {}
// </SECTION>
}

View File

@@ -1,11 +1,25 @@
<?php
/*
// MODULE_CONTRACT: Defines the data structure for a single step within a deal.
// RESPONSIBILITY: To hold and type-safely represent the details of a specific stage in a multi-step deal process.
// INPUTS: Raw JSON object from the API response.
// OUTPUTS: A structured object containing deal step details.
// LINKS: Requests/NominalAccounts/Deals/Steps/GetStepRequest.php
*/
namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals\Steps;
// <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 deal step.">
// <BELIEF_STATE "This DTO provides a clear, type-safe contract for a deal step, which is a critical component for defining and tracking complex business processes within a deal.">
class StepData extends Data
{
// <SECTION name="constructor_properties" intent="Define the properties of a deal step.">
// <BELIEF_STATE "The constructor includes key identifiers like `stepId` and `stepNumber`, along with `description`, `status`, and `isValid` to provide a comprehensive overview of the step's current state and details.">
public function __construct(
public string $stepId,
public int $stepNumber,
@@ -13,4 +27,5 @@ class StepData extends Data
public string $status,
public bool $isValid,
) {}
// </SECTION>
}