forked from apoloz/alfa-bank-sdk
Alfa BaaS documents PATCH on /beneficiaries/{id}/requisites/{id}; PUT returns 404.
Co-authored-by: Cursor <cursoragent@cursor.com>
49 lines
1.6 KiB
PHP
49 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
/*
|
|
// 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;
|
|
|
|
// <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;
|
|
|
|
public function __construct(
|
|
protected string $beneficiaryId,
|
|
protected string $requisiteId,
|
|
protected array $data
|
|
) {}
|
|
|
|
public function resolveEndpoint(): string
|
|
{
|
|
return "/api/na/jp/v1/beneficiaries/{$this->beneficiaryId}/requisites/{$this->requisiteId}";
|
|
}
|
|
|
|
public function createDtoFromResponse(Response $response): GeneralStatusData
|
|
{
|
|
return GeneralStatusData::from(['success' => $response->successful()]);
|
|
}
|
|
|
|
protected function defaultBody(): array
|
|
{
|
|
return $this->data;
|
|
}
|
|
}
|