forked from apoloz/alfa-bank-sdk
54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Apoloz\AlfaBank\Requests\Sandbox;
|
|
|
|
use Saloon\Contracts\Body\HasBody;
|
|
use Saloon\Enums\Method;
|
|
use Saloon\Http\Request;
|
|
use Saloon\Traits\Body\HasStringBody;
|
|
|
|
class SignatureEncryptionTestRequest extends Request implements HasBody
|
|
{
|
|
use HasStringBody;
|
|
|
|
protected Method $method = Method::POST;
|
|
|
|
/**
|
|
* @param string $data Raw content (JWS, TEXT or XML)
|
|
* @param string $format json|text|xml
|
|
* @param string $requestSecurity NO|SIGNATURE|ENCRYPTION
|
|
* @param string $responseSecurity NO|SIGNATURE|ENCRYPTION
|
|
*/
|
|
public function __construct(
|
|
protected string $data,
|
|
protected string $format = 'json',
|
|
protected string $requestSecurity = 'SIGNATURE',
|
|
protected string $responseSecurity = 'SIGNATURE'
|
|
) {}
|
|
|
|
public function resolveEndpoint(): string
|
|
{
|
|
return "/api/signature-encryption-tests/{$this->format}";
|
|
}
|
|
|
|
protected function defaultHeaders(): array
|
|
{
|
|
$headers = [
|
|
'X-Request-ChannelSecurity' => $this->requestSecurity,
|
|
'X-Response-ChannelSecurity' => $this->responseSecurity,
|
|
];
|
|
|
|
if ($this->format === 'json') {
|
|
$headers['Content-Type'] = 'application/jose';
|
|
}
|
|
|
|
return $headers;
|
|
}
|
|
|
|
protected function defineBody(): string
|
|
{
|
|
return $this->data;
|
|
}
|
|
} |