forked from apoloz/alfa-bank-sdk
first commit
This commit is contained in:
62
src/Sbp/Requests/DigitalRuble/CreateUniQrRequest.php
Normal file
62
src/Sbp/Requests/DigitalRuble/CreateUniQrRequest.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\DigitalRuble;
|
||||
|
||||
use Gemini\AlfaBank\Sbp\Data\DigitalRuble\CreateUniQrRequestData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class CreateUniQrRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected CreateUniQrRequestData $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
$body = [
|
||||
'command' => 'ReqUniQr',
|
||||
'TermNo' => $this->data->TermNo,
|
||||
'uniQrType' => $this->data->uniQrType,
|
||||
];
|
||||
|
||||
// Conditional mappings
|
||||
if ($this->data->amount !== null) $body['amount'] = $this->data->amount;
|
||||
if ($this->data->paymentPurpose !== null) $body['paymentPurpose'] = $this->data->paymentPurpose;
|
||||
if ($this->data->redirectUrl !== null) $body['redirectUrl'] = $this->data->redirectUrl;
|
||||
if ($this->data->paymentPageUrl !== null) $body['paymentPageUrl'] = $this->data->paymentPageUrl;
|
||||
if ($this->data->mediaType !== null) $body['mediaType'] = $this->data->mediaType;
|
||||
if ($this->data->width !== null) $body['width'] = $this->data->width;
|
||||
if ($this->data->height !== null) $body['height'] = $this->data->height;
|
||||
if ($this->data->qrTtl !== null) $body['qrTtl'] = $this->data->qrTtl;
|
||||
if ($this->data->messageID !== null) $body['messageID'] = $this->data->messageID;
|
||||
|
||||
$queryData = [];
|
||||
if ($this->data->notificationUrl !== null) $queryData['notificationUrl'] = $this->data->notificationUrl;
|
||||
if ($this->data->SenderFIO !== null) $queryData['SenderFIO'] = $this->data->SenderFIO;
|
||||
if ($this->data->SenderID !== null) $queryData['SenderID'] = $this->data->SenderID;
|
||||
if ($this->data->SenderBankBIC !== null) $queryData['SenderBankBIC'] = $this->data->SenderBankBIC;
|
||||
|
||||
if (!empty($queryData)) {
|
||||
$body['queryData'] = $queryData;
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(\Saloon\Http\Response $response): array
|
||||
{
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user