68 lines
3.2 KiB
PHP
68 lines
3.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
/*
|
|
// MODULE_CONTRACT: Represents the SBP API call to get a list of blocked QR Codes.
|
|
// RESPONSIBILITY: To define the POST request for retrieving all QR Codes that have been blocked for a terminal.
|
|
// INPUTS: Terminal number (TermNo).
|
|
// OUTPUTS: Raw array response from the API.
|
|
*/
|
|
|
|
namespace Apoloz\AlfaBank\Sbp\Requests\Management;
|
|
|
|
// <SECTION name="module_imports" intent="Import Saloon components for a JSON body request.">
|
|
// <BELIEF_STATE "This POST request utilizes `HasBody` and `HasJsonBody` for proper payload serialization. It currently returns a raw array response.">
|
|
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 get a list of blocked QR Codes.">
|
|
// <BELIEF_STATE "This class encapsulates the logic for querying blocked QR Codes, which is part of managing payment terminals.">
|
|
class GetBlockedQrListRequest extends Request implements HasBody
|
|
{
|
|
use HasJsonBody;
|
|
|
|
// <SECTION name="http_method" intent="Declare the HTTP verb.">
|
|
// <BELIEF_STATE "Even though it retrieves data, SBP list requests are often performed via POST requests with a JSON body.">
|
|
protected Method $method = Method::POST;
|
|
// </SECTION>
|
|
|
|
// <SECTION name="constructor" intent="Inject the mandatory terminal number.">
|
|
// <BELIEF_STATE "The constructor requires the `TermNo` to specify which terminal's blocked QR Codes are being queried.">
|
|
public function __construct(
|
|
protected string $TermNo
|
|
) {}
|
|
|
|
// <SECTION name="endpoint_resolver" intent="Define the endpoint for SBP blocked QR list queries.">
|
|
// <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 ''; // 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. The `TermNo` is included in the body to identify the terminal.">
|
|
protected function defaultBody(): array
|
|
{
|
|
return [
|
|
'command' => 'GetBlockedQRcIdList',
|
|
'TermNo' => $this->TermNo,
|
|
];
|
|
}
|
|
// </SECTION>
|
|
|
|
// <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 \Apoloz\AlfaBank\Sbp\Data\Management\GetBlockedQrListResponseData::from($response->json());
|
|
}
|
|
// </SECTION>
|
|
}
|