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,27 +1,49 @@
<?php
/*
// MODULE_CONTRACT: Represents the API call to retrieve a single deal by its ID.
// RESPONSIBILITY: To define the GET request structure for fetching a specific deal's details.
// INPUTS: Deal ID (string).
// OUTPUTS: DealData (DTO).
*/
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Deals;
// <SECTION name="module_imports" intent="Import DTO and Saloon components.">
// <BELIEF_STATE "This request needs the `DealData` DTO for its response and Saloon's base Request class.">
use Apoloz\AlfaBank\Data\NominalAccounts\Deals\DealData;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get a single deal.">
// <BELIEF_STATE "A dedicated class encapsulates the logic for this specific API endpoint, promoting reusability and separation of concerns.">
class GetDealRequest extends Request
{
// <SECTION name="http_method" intent="Declare the HTTP verb.">
// <BELIEF_STATE "Fetching a resource by its identifier is a read-only operation, making GET the correct RESTful verb.">
protected Method $method = Method::GET;
// </SECTION>
// <SECTION name="constructor" intent="Inject the deal's unique identifier.">
// <BELIEF_STATE "The `dealId` is a mandatory path parameter for this endpoint, so it must be required in the constructor.">
public function __construct(
protected string $dealId
) {}
// </SECTION>
// <SECTION name="endpoint_resolver" intent="Construct the request URI with the dynamic deal ID.">
// <BELIEF_STATE "The endpoint is dynamic. Injecting the `dealId` into the URI is handled here to keep the endpoint definition clean and centralized within the request class.">
public function resolveEndpoint(): string
{
return "/api/na/jp/v1/deals/{$this->dealId}";
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DealData DTO.">
// <BELIEF_STATE "Automated casting to a DTO provides type safety and a clean object-oriented interface for the API response.">
public function createDtoFromResponse(Response $response): DealData
{
return DealData::from($response->json());
}
// </SECTION>
}