Улучшена документация, добавлена поддержка цифрового рубля и улучшена структура DTO

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
2026-01-21 12:46:02 +03:00
parent 58affe3e97
commit 60c99bca40
30 changed files with 385 additions and 156 deletions

View File

@@ -59,11 +59,11 @@ class GetUniQrStatusRequest extends Request implements HasBody
}
// </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
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetUniQrStatusResponseData` DTO provides a type-safe and structured object for the status of Universal QR Codes.">
public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\DigitalRuble\GetUniQrStatusResponseData
{
return $response->json();
return \Apoloz\AlfaBank\Sbp\Data\DigitalRuble\GetUniQrStatusResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -48,28 +48,21 @@ class BlockQrRequest extends Request implements HasBody
// </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. The `TermNo` and `qrcId` identify the target, and `reason` provides context for the block.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Using the DTO's `toArray` method ensures the payload is correctly structured.">
protected function defaultBody(): array
{
$body = [
'command' => 'BlockQRcId',
'TermNo' => $this->data->TermNo,
'qrcId' => $this->data->qrcId,
];
if ($this->data->reason !== null) {
$body['reason'] = $this->data->reason;
}
return $body;
return array_merge(
['command' => 'BlockQRcId'],
$this->data->toArray()
);
}
// </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
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `SbpManagementResponseData` DTO provides a structured object for the result of the block operation.">
public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData
{
return $response->json();
return \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -57,11 +57,11 @@ class GetBlockedQrListRequest extends Request implements HasBody
}
// </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
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetBlockedQrListResponseData` DTO provides a type-safe object for the list of blocked QR Codes.">
public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Management\GetBlockedQrListResponseData
{
return $response->json();
return \Apoloz\AlfaBank\Sbp\Data\Management\GetBlockedQrListResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -48,22 +48,21 @@ class UnblockQrRequest extends Request implements HasBody
// </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. The `TermNo` and `qrcId` identify the target QR Code.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Using the DTO's `toArray` method ensures the payload is correctly structured.">
protected function defaultBody(): array
{
return [
'command' => 'UnblockQRcId',
'TermNo' => $this->data->TermNo,
'qrcId' => $this->data->qrcId,
];
return array_merge(
['command' => 'UnblockQRcId'],
$this->data->toArray()
);
}
// </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
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `SbpManagementResponseData` DTO provides a structured object for the result of the unblock operation.">
public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData
{
return $response->json();
return \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -50,21 +50,10 @@ class GetQrcReversalDataRequest extends Request implements HasBody
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Other fields from the DTO are conditionally added, ensuring the payload precisely matches the API specification.">
protected function defaultBody(): array
{
$body = [
'command' => 'GetQRCreversalData',
'TermNo' => $this->data->TermNo,
'currency' => $this->data->currency,
];
if ($this->data->qrcId !== null) $body['qrcId'] = $this->data->qrcId;
if ($this->data->payrrn !== null) $body['payrrn'] = $this->data->payrrn;
if ($this->data->trxId !== null) $body['trxId'] = $this->data->trxId;
if ($this->data->trxDT !== null) $body['trxDT'] = $this->data->trxDT;
if ($this->data->amount !== null) $body['amount'] = $this->data->amount;
if ($this->data->messageID !== null) $body['messageID'] = $this->data->messageID;
if ($this->data->ReturnRestAmount !== null) $body['ReturnRestAmount'] = $this->data->ReturnRestAmount;
return $body;
return array_merge(
['command' => 'GetQRCreversalData'],
$this->data->toArray()
);
}
// </SECTION>

View File

@@ -50,17 +50,10 @@ class GetQrcReversalStatusRequest extends Request implements HasBody
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Other fields from the DTO are conditionally added, ensuring the payload precisely matches the API specification.">
protected function defaultBody(): array
{
$body = [
'command' => 'GetQRCreversalStatus',
'TermNo' => $this->data->TermNo,
];
if ($this->data->payrrn !== null) $body['payrrn'] = $this->data->payrrn;
if ($this->data->originalTrxId !== null) $body['originalTrxId'] = $this->data->originalTrxId;
if ($this->data->trxId !== null) $body['trxId'] = $this->data->trxId;
if ($this->data->messageID !== null) $body['messageID'] = $this->data->messageID;
return $body;
return array_merge(
['command' => 'GetQRCreversalStatus'],
$this->data->toArray()
);
}
// </SECTION>

View File

@@ -50,22 +50,10 @@ class QrcReversalRequest extends Request implements HasBody
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Other fields from the DTO are conditionally added, ensuring the payload precisely matches the API specification.">
protected function defaultBody(): array
{
$body = [
'command' => 'QRCreversal',
'TermNo' => $this->data->TermNo,
'currency' => $this->data->currency,
];
if ($this->data->qrcId !== null) $body['qrcId'] = $this->data->qrcId;
if ($this->data->payrrn !== null) $body['payrrn'] = $this->data->payrrn;
if ($this->data->trxId !== null) $body['trxId'] = $this->data->trxId;
if ($this->data->trxDT !== null) $body['trxDT'] = $this->data->trxDT;
if ($this->data->amount !== null) $body['amount'] = $this->data->amount;
if ($this->data->messageID !== null) $body['messageID'] = $this->data->messageID;
if ($this->data->notificationUrl !== null) $body['queryData'] = ['notificationUrl' => $this->data->notificationUrl];
if ($this->data->ReturnRestAmount !== null) $body['ReturnRestAmount'] = $this->data->ReturnRestAmount;
return $body;
return array_merge(
['command' => 'QRCreversal'],
$this->data->toArray()
);
}
// </SECTION>

View File

@@ -50,16 +50,10 @@ class GetQrcStatusRequest extends Request implements HasBody
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. The `TermNo` is mandatory, and `qrcId`, `payrrn`, and `messageID` are optional filters to pinpoint the transaction.">
protected function defaultBody(): array
{
$body = [
'command' => 'GetQRCstatus',
'TermNo' => $this->data->TermNo,
];
if ($this->data->qrcId !== null) $body['qrcId'] = $this->data->qrcId;
if ($this->data->payrrn !== null) $body['payrrn'] = $this->data->payrrn;
if ($this->data->messageID !== null) $body['messageID'] = $this->data->messageID;
return $body;
return array_merge(
['command' => 'GetQRCstatus'],
$this->data->toArray()
);
}
// </SECTION>

View File

@@ -66,11 +66,11 @@ class GetQrSubStatusRequest extends Request implements HasBody
}
// </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
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetQrSubStatusResponseData` DTO provides a structured object for the status of the subscription.">
public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Subscription\GetQrSubStatusResponseData
{
return $response->json();
return \Apoloz\AlfaBank\Sbp\Data\Subscription\GetQrSubStatusResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -61,11 +61,11 @@ class QrcSubPayPetitionRequest extends Request implements HasBody
}
// </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(Response $response): array
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `QrcSubPayPetitionResponseData` DTO provides a structured object for the result of the payment petition.">
public function createDtoFromResponse(Response $response): \Apoloz\AlfaBank\Sbp\Data\Subscription\QrcSubPayPetitionResponseData
{
return $response->json();
return \Apoloz\AlfaBank\Sbp\Data\Subscription\QrcSubPayPetitionResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -46,33 +46,21 @@ class RegQrSubRequest extends Request implements HasBody
// </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 notification URLs.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Using the DTO's `toArray` method ensures the payload is correctly structured.">
protected function defaultBody(): array
{
$body = [
'command' => 'RegQRcSub',
'TermNo' => $this->data->TermNo,
'qrcType' => $this->data->qrcType,
'subscriptionPurpose' => $this->data->subscriptionPurpose,
'queryData' => [
'notificationUrl' => $this->data->notificationUrl,
],
];
if ($this->data->qrTtl !== null) $body['qrTtl'] = $this->data->qrTtl;
if ($this->data->redirectUrl !== null) $body['redirectUrl'] = $this->data->redirectUrl;
if ($this->data->subscriptionServiceId !== null) $body['subscriptionServiceId'] = $this->data->subscriptionServiceId;
if ($this->data->subscriptionServiceName !== null) $body['subscriptionServiceName'] = $this->data->subscriptionServiceName;
return $body;
return array_merge(
['command' => 'RegQRcSub'],
$this->data->toArray()
);
}
// </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(Response $response): array
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `RegQrSubResponseData` DTO provides a structured object for the result of the subscription registration.">
public function createDtoFromResponse(Response $response): \Apoloz\AlfaBank\Sbp\Data\Subscription\RegQrSubResponseData
{
return $response->json();
return \Apoloz\AlfaBank\Sbp\Data\Subscription\RegQrSubResponseData::from($response->json());
}
// </SECTION>
}