forked from apoloz/alfa-bank-sdk
refactor(core): enhance SDK structure and documentation
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -1,28 +1,51 @@
|
||||
<?php
|
||||
/*
|
||||
// MODULE_CONTRACT: Represents the API call to retrieve a single step for a specific deal.
|
||||
// RESPONSIBILITY: To define the GET request for fetching details of a particular deal step.
|
||||
// INPUTS: Deal ID, step ID.
|
||||
// OUTPUTS: StepData (DTO).
|
||||
*/
|
||||
|
||||
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Deals\Steps;
|
||||
|
||||
// <SECTION name="module_imports" intent="Import DTO and Saloon components.">
|
||||
// <BELIEF_STATE "This request requires the `StepData` DTO for its response.">
|
||||
use Apoloz\AlfaBank\Data\NominalAccounts\Deals\Steps\StepData;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define the request to get a single deal step.">
|
||||
// <BELIEF_STATE "A dedicated class provides a clean and reusable way to fetch details of a specific step within a deal.">
|
||||
class GetStepRequest 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 deal ID and step ID.">
|
||||
// <BELIEF_STATE "Both `dealId` and `stepId` are mandatory path parameters to identify the specific step being queried.">
|
||||
public function __construct(
|
||||
protected string $dealId,
|
||||
protected string $stepId
|
||||
) {}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="endpoint_resolver" intent="Construct the request URI for a specific deal step.">
|
||||
// <BELIEF_STATE "The endpoint is dynamically constructed with both `dealId` and `stepId` to target the precise step resource.">
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return "/api/na/jp/v1/deals/{$this->dealId}/steps/{$this->stepId}";
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_caster" intent="Map the JSON response to a StepData DTO.">
|
||||
// <BELIEF_STATE "Automated casting to a `StepData` DTO ensures a type-safe and comprehensive object representation of the deal step.">
|
||||
public function createDtoFromResponse(Response $response): StepData
|
||||
{
|
||||
return StepData::from($response->json());
|
||||
}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user