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,28 +1,52 @@
<?php
/*
// MODULE_CONTRACT: Represents the SBP API call to create a Universal QR Code for Digital Ruble.
// RESPONSIBILITY: To define the POST request for generating a new Uni QR Code for digital ruble transactions.
// INPUTS: CreateUniQrRequestData (DTO) containing QR Code parameters.
// OUTPUTS: Raw array response from the API.
*/
namespace Apoloz\AlfaBank\Sbp\Requests\DigitalRuble;
// <SECTION name="module_imports" intent="Import DTO and Saloon components for a JSON body request.">
// <BELIEF_STATE "This POST request requires the `CreateUniQrRequestData` DTO for its JSON body and utilizes `HasBody` and `HasJsonBody` for proper payload serialization. It currently returns a raw array response.">
use Apoloz\AlfaBank\Sbp\Data\DigitalRuble\CreateUniQrRequestData;
use Saloon\Contracts\Body\HasBody;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Traits\Body\HasJsonBody;
// <BELIEF_STATE "The `Response` object is fully qualified in `createDtoFromResponse` as it is not explicitly imported with a `use` statement at the top. This is acceptable but less explicit.">
// use Saloon\Http\Response; // Explicit import would be cleaner
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to create a Universal QR Code.">
// <BELIEF_STATE "This class encapsulates the logic for generating a Uni QR Code for digital ruble, a key feature in the SBP Digital Ruble operations.">
class CreateUniQrRequest extends Request implements HasBody
{
use HasJsonBody;
// <SECTION name="http_method" intent="Declare the HTTP verb.">
// <BELIEF_STATE "Creating a new QR Code resource or initiating a generation action is correctly represented by a POST request.">
protected Method $method = Method::POST;
// </SECTION>
// <SECTION name="constructor" intent="Inject the DTO containing the Uni QR Code creation data.">
// <BELIEF_STATE "Using a strongly-typed DTO (`CreateUniQrRequestData`) ensures that all necessary information for QR Code generation is provided and correctly structured.">
public function __construct(
protected CreateUniQrRequestData $data
) {}
// <SECTION name="endpoint_resolver" intent="Define the endpoint for SBP Uni QR Code creation.">
// <BELIEF_STATE "The SBP API often uses generic endpoints with a 'command' field in the body, implying the endpoint itself might be empty or a base SBP URL.">
public function resolveEndpoint(): string
{
return '';
return ''; // Endpoint is determined by SbpConnector's base URL
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Fields from the DTO are mapped, including conditional and nested `queryData` for sender information and notification URLs.">
protected function defaultBody(): array
{
$body = [
@@ -54,9 +78,13 @@ class CreateUniQrRequest extends Request implements HasBody
return $body;
}
// </SECTION>
// <SECTION name="response_caster" intent="Return the raw JSON response as an array.">
// <BELIEF_STATE "For this specific request, the response is currently returned as a raw array. A dedicated DTO could be created if a structured object is required.">
public function createDtoFromResponse(\Saloon\Http\Response $response): array
{
return $response->json();
}
// </SECTION>
}