forked from apoloz/alfa-bank-sdk
refactor(Sbp)
This commit is contained in:
@@ -6,15 +6,16 @@ namespace Apoloz\AlfaBank\Sbp\Requests\DigitalRuble;
|
||||
|
||||
use Apoloz\AlfaBank\Sbp\Data\DigitalRuble\CreateUniQrRequestData;
|
||||
use Apoloz\AlfaBank\Sbp\Data\DigitalRuble\UniQrResponseData;
|
||||
use Apoloz\AlfaBank\Utils\CmsSigner;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
use Saloon\Traits\Body\HasStringBody;
|
||||
|
||||
class CreateUniQrRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
use HasStringBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
@@ -32,40 +33,40 @@ class CreateUniQrRequest extends Request implements HasBody
|
||||
return UniQrResponseData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
protected function defaultBody(): string
|
||||
{
|
||||
$body = [
|
||||
$bodyArray = [
|
||||
'command' => 'ReqUniQr',
|
||||
'TermNo' => $this->data->TermNo,
|
||||
'uniQrType' => $this->data->uniQrType,
|
||||
];
|
||||
|
||||
if ($this->data->amount !== null) {
|
||||
$body['amount'] = $this->data->amount;
|
||||
$bodyArray['amount'] = $this->data->amount;
|
||||
}
|
||||
if ($this->data->paymentPurpose !== null) {
|
||||
$body['paymentPurpose'] = $this->data->paymentPurpose;
|
||||
$bodyArray['paymentPurpose'] = $this->data->paymentPurpose;
|
||||
}
|
||||
if ($this->data->redirectUrl !== null) {
|
||||
$body['redirectUrl'] = $this->data->redirectUrl;
|
||||
$bodyArray['redirectUrl'] = $this->data->redirectUrl;
|
||||
}
|
||||
if ($this->data->paymentPageUrl !== null) {
|
||||
$body['paymentPageUrl'] = $this->data->paymentPageUrl;
|
||||
$bodyArray['paymentPageUrl'] = $this->data->paymentPageUrl;
|
||||
}
|
||||
if ($this->data->mediaType !== null) {
|
||||
$body['mediaType'] = $this->data->mediaType;
|
||||
$bodyArray['mediaType'] = $this->data->mediaType;
|
||||
}
|
||||
if ($this->data->width !== null) {
|
||||
$body['width'] = $this->data->width;
|
||||
$bodyArray['width'] = $this->data->width;
|
||||
}
|
||||
if ($this->data->height !== null) {
|
||||
$body['height'] = $this->data->height;
|
||||
$bodyArray['height'] = $this->data->height;
|
||||
}
|
||||
if ($this->data->qrTtl !== null) {
|
||||
$body['qrTtl'] = $this->data->qrTtl;
|
||||
$bodyArray['qrTtl'] = $this->data->qrTtl;
|
||||
}
|
||||
if ($this->data->messageID !== null) {
|
||||
$body['messageID'] = $this->data->messageID;
|
||||
$bodyArray['messageID'] = $this->data->messageID;
|
||||
}
|
||||
|
||||
$queryData = [];
|
||||
@@ -83,9 +84,9 @@ class CreateUniQrRequest extends Request implements HasBody
|
||||
}
|
||||
|
||||
if (! empty($queryData)) {
|
||||
$body['queryData'] = $queryData;
|
||||
$bodyArray['queryData'] = $queryData;
|
||||
}
|
||||
|
||||
return $body;
|
||||
return CmsSigner::canonicalize($bodyArray);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user