Files
alfa-bank-sdk/src/Requests/NominalAccounts/Beneficiaries/Requisites/UpdateRequisiteRequest.php

47 lines
1.5 KiB
PHP

<?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;
// <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::PUT;
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}";
}
protected function defaultBody(): array
{
return $this->data;
}
public function createDtoFromResponse(Response $response): GeneralStatusData
{
return GeneralStatusData::from(['success' => $response->successful()]);
}
}