52 lines
1.6 KiB
PHP
52 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Gemini\AlfaBank\Sbp\Requests\Reversal;
|
|
|
|
use Gemini\AlfaBank\Sbp\Data\Reversal\GetQrcReversalDataRequestData;
|
|
use Gemini\AlfaBank\Sbp\Data\Reversal\GetQrcReversalDataResponseData;
|
|
use Saloon\Contracts\Body\HasBody;
|
|
use Saloon\Enums\Method;
|
|
use Saloon\Http\Request;
|
|
use Saloon\Http\Response;
|
|
use Saloon\Traits\Body\HasJsonBody;
|
|
|
|
class GetQrcReversalDataRequest extends Request implements HasBody
|
|
{
|
|
use HasJsonBody;
|
|
|
|
protected Method $method = Method::POST;
|
|
|
|
public function __construct(
|
|
protected GetQrcReversalDataRequestData $data
|
|
) {}
|
|
|
|
public function resolveEndpoint(): string
|
|
{
|
|
return '';
|
|
}
|
|
|
|
protected function defaultBody(): array
|
|
{
|
|
$body = [
|
|
'command' => 'GetQRCreversalData',
|
|
'TermNo' => $this->data->TermNo,
|
|
'currency' => $this->data->currency,
|
|
];
|
|
|
|
if ($this->data->qrcId !== null) $body['qrcId'] = $this->data->qrcId;
|
|
if ($this->data->payrrn !== null) $body['payrrn'] = $this->data->payrrn;
|
|
if ($this->data->trxId !== null) $body['trxId'] = $this->data->trxId;
|
|
if ($this->data->trxDT !== null) $body['trxDT'] = $this->data->trxDT;
|
|
if ($this->data->amount !== null) $body['amount'] = $this->data->amount;
|
|
if ($this->data->messageID !== null) $body['messageID'] = $this->data->messageID;
|
|
if ($this->data->ReturnRestAmount !== null) $body['ReturnRestAmount'] = $this->data->ReturnRestAmount;
|
|
|
|
return $body;
|
|
}
|
|
|
|
public function createDtoFromResponse(Response $response): GetQrcReversalDataResponseData
|
|
{
|
|
return GetQrcReversalDataResponseData::from($response->json());
|
|
}
|
|
}
|