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,17 +1,32 @@
|
||||
<?php
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a paginated collection of DealData objects.
|
||||
// RESPONSIBILITY: To provide a structured, type-safe container for lists of deals returned by the API, including pagination metadata.
|
||||
// INPUTS: Raw JSON array from the API response.
|
||||
// OUTPUTS: An object containing pagination details and a collection of `DealData`.
|
||||
// LINKS: Requests/NominalAccounts/Deals/GetDealsRequest.php
|
||||
*/
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals;
|
||||
|
||||
// <SECTION name="module_imports" intent="Import necessary DTOs and Spatie Laravel Data components.">
|
||||
// <BELIEF_STATE "This collection DTO relies on `PaginationData` for metadata and `DealData` for the individual items. `DataCollection` and `DataCollectionOf` are Spatie Data features for handling typed arrays of DTOs.">
|
||||
use Apoloz\AlfaBank\Data\PaginationData;
|
||||
use Spatie\LaravelData\Attributes\DataCollectionOf;
|
||||
use Spatie\LaravelData\Data;
|
||||
use Spatie\LaravelData\DataCollection;
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define a DTO for a collection of deals.">
|
||||
// <BELIEF_STATE "A dedicated DTO for a collection ensures that the structure of paginated lists is consistent and type-safe, providing a reliable contract for consumers to manage deals.">
|
||||
class DealCollectionData extends Data
|
||||
{
|
||||
// <SECTION name="constructor_properties" intent="Define the properties of the deal collection.">
|
||||
// <BELIEF_STATE "The collection structure includes pagination metadata (`pagination`) and the actual list of deals (`deals`). The `#[DataCollectionOf(DealData::class)]` attribute is crucial for ensuring that each item in the `deals` array is automatically cast to a `DealData` DTO.">
|
||||
public function __construct(
|
||||
public PaginationData $pagination,
|
||||
#[DataCollectionOf(DealData::class)]
|
||||
public DataCollection $deals
|
||||
) {}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
@@ -1,15 +1,30 @@
|
||||
<?php
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a single deal.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the core attributes of a deal, such as its ID, status, and expiration.
|
||||
// INPUTS: Raw JSON object from the API response.
|
||||
// OUTPUTS: A structured object containing deal details.
|
||||
// LINKS: DealCollectionData.php, Requests/NominalAccounts/Deals/GetDealRequest.php
|
||||
*/
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals;
|
||||
|
||||
// <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's details.">
|
||||
// <BELIEF_STATE "This DTO provides a comprehensive, type-safe representation of a deal, essential for consistent data handling across the SDK.">
|
||||
class DealData extends Data
|
||||
{
|
||||
// <SECTION name="constructor_properties" intent="Define all properties that describe a deal.">
|
||||
// <BELIEF_STATE "The constructor includes mandatory fields such as `dealId` (unique identifier), `status` (current state), `expireDate`, and `isValid` (indicating payment readiness).">
|
||||
public function __construct(
|
||||
public string $dealId,
|
||||
public string $status,
|
||||
public string $expireDate,
|
||||
public bool $isValid,
|
||||
) {}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
@@ -1,11 +1,25 @@
|
||||
<?php
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a single payoff within a deal.
|
||||
// RESPONSIBILITY: To hold and type-safely represent a specific payment made as part of a deal.
|
||||
// INPUTS: Raw JSON object from the API response.
|
||||
// OUTPUTS: A structured object containing deal payoff details.
|
||||
// LINKS: Requests/NominalAccounts/Deals/GetDealPayoffsRequest.php
|
||||
*/
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals;
|
||||
|
||||
// <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 payoff associated with a deal.">
|
||||
// <BELIEF_STATE "This DTO provides a clear, type-safe contract for individual payment records related to a deal, crucial for tracking financial flows within deals.">
|
||||
class DealPayoffData extends Data
|
||||
{
|
||||
// <SECTION name="constructor_properties" intent="Define the properties of a deal payoff.">
|
||||
// <BELIEF_STATE "The constructor includes key identifiers like `stepId`, `payoffId`, `payoffType`, `deponentId`, `recipientId`, and financial details (`amount`, `status`). These fields are essential for understanding the specific payment within the context of a deal.">
|
||||
public function __construct(
|
||||
public string $stepId,
|
||||
public string $payoffId,
|
||||
@@ -15,4 +29,5 @@ class DealPayoffData extends Data
|
||||
public string $amount,
|
||||
public string $status,
|
||||
) {}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
@@ -1,14 +1,29 @@
|
||||
<?php
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the status of a deal-related request.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the outcome and details of an asynchronous operation related to deals.
|
||||
// INPUTS: Raw JSON object from the API response.
|
||||
// OUTPUTS: A structured object containing request status information.
|
||||
// LINKS: Requests/NominalAccounts/Deals/GetDealRequestStatusRequest.php
|
||||
*/
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals;
|
||||
|
||||
// <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 status of a deal request.">
|
||||
// <BELIEF_STATE "This DTO provides a clear, type-safe contract for tracking the status of asynchronous deal operations, which is common for complex business processes.">
|
||||
class DealRequestStatusData extends Data
|
||||
{
|
||||
// <SECTION name="constructor_properties" intent="Define the properties of a deal request status.">
|
||||
// <BELIEF_STATE "The `requestId` and `status` are fundamental for tracking any asynchronous operation. An optional `description` can provide further details about the status.">
|
||||
public function __construct(
|
||||
public string $requestId,
|
||||
public string $status,
|
||||
public ?string $description = null,
|
||||
) {}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -1,14 +1,29 @@
|
||||
<?php
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the response of a deal validation request.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the outcome of checking a deal's validity.
|
||||
// INPUTS: Raw JSON object from the API response.
|
||||
// OUTPUTS: A structured object containing deal validation status.
|
||||
// LINKS: Requests/NominalAccounts/Deals/ValidateDealRequest.php
|
||||
*/
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals;
|
||||
|
||||
// <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 deal validation.">
|
||||
// <BELIEF_STATE "This DTO provides a clear, type-safe contract for understanding whether a deal is considered valid for further operations, including an optional description for validation failures.">
|
||||
class ValidateDealResponseData extends Data
|
||||
{
|
||||
// <SECTION name="constructor_properties" intent="Define the properties of a deal validation response.">
|
||||
// <BELIEF_STATE "The constructor includes the `dealId` for context, a boolean `isValid` to indicate the validation outcome, and an optional `description` to provide details for invalid deals.">
|
||||
public function __construct(
|
||||
public string $dealId,
|
||||
public bool $isValid,
|
||||
public ?array $description = null,
|
||||
public ?array $description = null, // Can be a string or array of error messages
|
||||
) {}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user