forked from apoloz/alfa-bank-sdk
refactor(Sbp)
This commit is contained in:
@@ -18,7 +18,6 @@ use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
// </SECTION>
|
||||
|
||||
@@ -26,7 +25,7 @@ use Saloon\Traits\Body\HasJsonBody;
|
||||
// <BELIEF_STATE "This class encapsulates the logic for generating a Digital Ruble CashLink QR Code, a key feature in the SBP Digital Ruble operations.">
|
||||
class CreateCashUniQrRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
use HasStringBody;
|
||||
|
||||
// <SECTION name="http_method" intent="Declare the HTTP verb.">
|
||||
// <BELIEF_STATE "Creating a new QR Code resource or initiating a generation action is correctly represented by a POST request.">
|
||||
@@ -57,40 +56,40 @@ class CreateCashUniQrRequest extends Request implements HasBody
|
||||
|
||||
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
|
||||
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Fields from the DTO are mapped, including conditional and nested `queryData` for notification URLs.">
|
||||
protected function defaultBody(): array
|
||||
protected function defaultBody(): string
|
||||
{
|
||||
$body = [
|
||||
$bodyArray = [
|
||||
'command' => 'ReqCashUniQr',
|
||||
'TermNo' => $this->data->TermNo,
|
||||
];
|
||||
|
||||
if ($this->data->messageID !== null) {
|
||||
$body['messageID'] = $this->data->messageID;
|
||||
$bodyArray['messageID'] = $this->data->messageID;
|
||||
}
|
||||
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->qrcId !== null) {
|
||||
$body['qrcId'] = $this->data->qrcId;
|
||||
$bodyArray['qrcId'] = $this->data->qrcId;
|
||||
}
|
||||
|
||||
if ($this->data->notificationUrl !== null) {
|
||||
$body['queryData'] = ['notificationUrl' => $this->data->notificationUrl];
|
||||
$bodyArray['queryData'] = ['notificationUrl' => $this->data->notificationUrl];
|
||||
}
|
||||
|
||||
return $body;
|
||||
return CmsSigner::canonicalize($bodyArray);
|
||||
}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user