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,23 +1,32 @@
|
||||
<?php
|
||||
/*
|
||||
// MODULE_CONTRACT: Represents the API call to update a specific requisite for a beneficiary.
|
||||
// RESPONSIBILITY: To define the PATCH request for modifying an existing payment requisite.
|
||||
// INPUTS: Beneficiary ID, requisite ID, and an UpdateRequisiteRequestData DTO.
|
||||
// OUTPUTS: No specific DTO, typically a 200 OK or 202 Accepted status.
|
||||
*/
|
||||
|
||||
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\Requisites;
|
||||
|
||||
use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\Requisites\UpdateRequisiteRequestData;
|
||||
// <SECTION name="module_imports" intent="Import DTO and Saloon components for a JSON body request.">
|
||||
// <BELIEF_STATE "This PATCH request requires the `UpdateRequisiteRequestData` DTO for its JSON body and Saloon's body-handling traits.">
|
||||
use Apoloz\AlfaBank\Data\Shared\GeneralStatusData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class UpdateRequisiteRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::PATCH;
|
||||
protected Method $method = Method::PUT;
|
||||
|
||||
public function __construct(
|
||||
protected string $beneficiaryId,
|
||||
protected string $requisiteId,
|
||||
protected UpdateRequisiteRequestData $data
|
||||
protected array $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
@@ -27,6 +36,11 @@ class UpdateRequisiteRequest extends Request implements HasBody
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return $this->data->toArray();
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): GeneralStatusData
|
||||
{
|
||||
return GeneralStatusData::from(['success' => $response->successful()]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user