Files
alfa-bank-sdk/src/Sbp/Requests/CashLink/RegCashQrRequest.php
2026-01-14 16:50:27 +03:00

49 lines
1.4 KiB
PHP

<?php
namespace Apoloz\AlfaBank\Sbp\Requests\CashLink;
use Apoloz\AlfaBank\Sbp\Data\CashLink\RegCashQrRequestData;
use Apoloz\AlfaBank\Sbp\Data\CashLink\RegCashQrResponseData;
use Saloon\Contracts\Body\HasBody;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
class RegCashQrRequest extends Request implements HasBody
{
use HasJsonBody;
protected Method $method = Method::POST;
public function __construct(
protected RegCashQrRequestData $data
) {}
public function resolveEndpoint(): string
{
return '';
}
protected function defaultBody(): array
{
$body = [
'command' => 'RegCashQRc',
'TermNo' => $this->data->TermNo,
];
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->redirectUrl !== null) $body['redirectUrl'] = $this->data->redirectUrl;
if ($this->data->qrcId !== null) $body['qrcId'] = $this->data->qrcId;
return $body;
}
public function createDtoFromResponse(Response $response): RegCashQrResponseData
{
return RegCashQrResponseData::from($response->json());
}
}