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,41 +1,44 @@
|
||||
<?php
|
||||
/*
|
||||
// MODULE_CONTRACT: Represents a Sandbox API call for testing signature and encryption mechanisms.
|
||||
// RESPONSIBILITY: To define a POST request for sending a JWS (JSON Web Signature) body to the sandbox to verify cryptographic operations.
|
||||
// INPUTS: JWS body string, and desired security types for request/response channels.
|
||||
// OUTPUTS: No specific DTO; the response content needs manual parsing for verification.
|
||||
*/
|
||||
|
||||
namespace Apoloz\AlfaBank\Requests\Sandbox;
|
||||
|
||||
// <SECTION name="module_imports" intent="Import Saloon framework components for handling string bodies.">
|
||||
// <BELIEF_STATE "This POST request sends a raw string (JWS) as its body, so `HasStringBody` is the appropriate trait.">
|
||||
use Apoloz\AlfaBank\Data\Sandbox\SandboxTestResponseData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Traits\Body\HasStringBody;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class SignatureEncryptionTestRequest extends Request implements HasBody
|
||||
{
|
||||
use HasStringBody;
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected string $jwsBody,
|
||||
protected string $requestChannelSecurity = 'SIGNATURE',
|
||||
protected string $responseChannelSecurity = 'SIGNATURE'
|
||||
protected string $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '/api/signature-encryption-tests/json';
|
||||
}
|
||||
|
||||
protected function defaultHeaders(): array
|
||||
{
|
||||
return [
|
||||
'Accept' => 'application/jose',
|
||||
'Content-Type' => 'application/jose',
|
||||
'X-Request-ChannelSecurity' => $this->requestChannelSecurity,
|
||||
'X-Response-ChannelSecurity' => $this->responseChannelSecurity,
|
||||
];
|
||||
return '/api/sandbox/v1/test/signature-encryption';
|
||||
}
|
||||
|
||||
protected function defaultBody(): ?string
|
||||
{
|
||||
return $this->jwsBody;
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): SandboxTestResponseData
|
||||
{
|
||||
return SandboxTestResponseData::from(['result' => $response->body()]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user