54 lines
2.3 KiB
PHP
54 lines
2.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
/*
|
|
// MODULE_CONTRACT: Represents the API call to retrieve details of a specific payoff.
|
|
// RESPONSIBILITY: To define the GET request for fetching detailed information about a particular payment.
|
|
// INPUTS: Payoff ID (string).
|
|
// OUTPUTS: DetailedPayoffData (DTO).
|
|
*/
|
|
|
|
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Payouts;
|
|
|
|
// <SECTION name="module_imports" intent="Import DTO and Saloon components.">
|
|
// <BELIEF_STATE "This request requires the `DetailedPayoffData` DTO for its comprehensive response.">
|
|
use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DetailedPayoffData;
|
|
use Saloon\Enums\Method;
|
|
use Saloon\Http\Request;
|
|
use Saloon\Http\Response;
|
|
|
|
// </SECTION>
|
|
|
|
// <SECTION name="class_definition" intent="Define the request to get details of a payoff.">
|
|
// <BELIEF_STATE "A dedicated class provides a clean and reusable way to fetch details of a specific payment.">
|
|
class GetPayoffRequest extends Request
|
|
{
|
|
// <SECTION name="http_method" intent="Declare the HTTP verb.">
|
|
// <BELIEF_STATE "Retrieving a specific resource by its ID is a read-only operation, making GET the correct RESTful verb.">
|
|
protected Method $method = Method::GET;
|
|
// </SECTION>
|
|
|
|
// <SECTION name="constructor" intent="Inject the payoff's unique identifier.">
|
|
// <BELIEF_STATE "The `payoffId` is a mandatory path parameter for this endpoint.">
|
|
public function __construct(
|
|
protected string $payoffId
|
|
) {}
|
|
// </SECTION>
|
|
|
|
// <SECTION name="endpoint_resolver" intent="Construct the request URI with the dynamic payoff ID.">
|
|
// <BELIEF_STATE "The endpoint is dynamically constructed with the `payoffId` to target the specific payment resource.">
|
|
public function resolveEndpoint(): string
|
|
{
|
|
return "/api/na/jp/v1/payoffs/{$this->payoffId}";
|
|
}
|
|
// </SECTION>
|
|
|
|
// <SECTION name="response_caster" intent="Map the JSON response to a DetailedPayoffData DTO.">
|
|
// <BELIEF_STATE "Automated casting to a `DetailedPayoffData` DTO ensures a type-safe and comprehensive object representation of the payoff, which is crucial for financial reconciliation.">
|
|
public function createDtoFromResponse(Response $response): DetailedPayoffData
|
|
{
|
|
return DetailedPayoffData::from($response->json());
|
|
}
|
|
// </SECTION>
|
|
}
|