forked from apoloz/alfa-bank-sdk
Улучшена документация, добавлена поддержка цифрового рубля и улучшена структура DTO
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -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>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user