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,30 +1,46 @@
|
||||
<?php
|
||||
/*
|
||||
// MODULE_CONTRACT: Represents the API call to perform an action on a deal contractor.
|
||||
// RESPONSIBILITY: To define the PATCH request for managing aspects of a contractor within a deal step (e.g., adding funds, setting requisites).
|
||||
// INPUTS: ContractorActionRequestData DTO.
|
||||
// OUTPUTS: No specific DTO, typically a 200 OK or 202 Accepted status.
|
||||
*/
|
||||
|
||||
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Deals\Steps;
|
||||
|
||||
use Apoloz\AlfaBank\Data\NominalAccounts\Deals\Steps\ContractorActionRequestData;
|
||||
// <SECTION name="module_imports" intent="Import DTO and Saloon components for a JSON body request.">
|
||||
// <BELIEF_STATE "This PATCH request requires the `ContractorActionRequestData` 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 ManageContractorRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::PATCH;
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected ContractorActionRequestData $data
|
||||
protected string $dealId,
|
||||
protected string $stepId,
|
||||
protected array $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '/api/na/jp/v1/deals/steps/contractors';
|
||||
return "/api/na/jp/v1/deals/{$this->dealId}/steps/{$this->stepId}/contractors";
|
||||
}
|
||||
|
||||
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