fix(certs)

This commit is contained in:
Anatoliy Poloz
2026-01-28 02:47:39 +03:00
parent d89a78bef2
commit 1723177949
5 changed files with 473 additions and 22 deletions

View File

@@ -15,18 +15,19 @@ namespace Apoloz\AlfaBank\Sbp\Requests;
// <BELIEF_STATE "A Request class needs its specific data transfer objects (DTOs) for the request payload and the response. It also requires Saloon's base classes and traits to function within the framework.">
use Apoloz\AlfaBank\Sbp\Data\QrCodeRequestData;
use Apoloz\AlfaBank\Sbp\Data\QrCodeResponseData;
use Apoloz\AlfaBank\Utils\CmsSigner;
use Saloon\Contracts\Body\HasBody;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
use Saloon\Traits\Body\HasStringBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define a class that encapsulates all information for the 'Get QR Code' API call.">
// <BELIEF_STATE "Using a dedicated class for each API request is a core Saloon pattern. It organizes the endpoint, method, body, and response handling into a single, reusable, and testable unit. Implementing `HasBody` and using `HasJsonBody` signals its intent to send a JSON payload.">
class GetQrCodeRequest extends Request implements HasBody
{
use HasJsonBody;
use HasStringBody;
// <SECTION name="http_method_declaration" intent="Declare the HTTP verb for this API operation.">
// <BELIEF_STATE "The SBP specification requires a POST request to generate a QR code, as the operation creates a new resource on the server.">
@@ -44,15 +45,19 @@ class GetQrCodeRequest extends Request implements HasBody
// <BELIEF_STATE "Centralizing the endpoint path in this method makes the SDK resilient to API changes. If the endpoint moves from '/qrcs' to '/v2/qrcs', this is the only line that needs to be updated for this specific request.">
public function resolveEndpoint(): string
{
return '/qrcs';
return '/';
}
// </SECTION>
// <SECTION name="request_body_builder" intent="Prepare the request payload for transmission.">
// <BELIEF_STATE "This method delegates the serialization logic to the `QrCodeRequestData` DTO. This is a key decoupling principle: the Request class shouldn't know *how* to serialize the data (e.g., mapping camelCase to PascalCase); it should only know that the DTO is responsible for providing a valid array representation.">
protected function defaultBody(): array
// <BELIEF_STATE "This method builds the request body by adding the required 'command' field and merging the DTO data. The SBP API requires the 'command' field to identify the operation type. The 'GetQRCd' command is used for both static and dynamic QR code generation.">
protected function defaultBody(): string
{
return $this->data->toArray();
$bodyArray = array_merge(
['command' => 'GetQRCd'],
$this->data->toArray()
);
return CmsSigner::canonicalize($bodyArray);
}
// </SECTION>