forked from apoloz/alfa-bank-sdk
fix(formating)
This commit is contained in:
@@ -19,6 +19,7 @@ use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define the request to change the account for a CashLink Uni QR Code.">
|
||||
@@ -46,6 +47,14 @@ class ChangeAccForCashUniQrRequest extends Request implements HasBody
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
|
||||
// <BELIEF_STATE "Casting the response to a `ChangeAccForCashUniQrResponseData` DTO provides a type-safe and structured object for the result of the account change operation.">
|
||||
public function createDtoFromResponse(Response $response): ChangeAccForCashUniQrResponseData
|
||||
{
|
||||
return ChangeAccForCashUniQrResponseData::from($response->json());
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <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 parameters for the new account, merchant, redirect URL, etc.">
|
||||
protected function defaultBody(): array
|
||||
@@ -55,25 +64,35 @@ class ChangeAccForCashUniQrRequest extends Request implements HasBody
|
||||
'TermNo' => $this->data->TermNo,
|
||||
];
|
||||
|
||||
if ($this->data->messageID !== null) $body['messageID'] = $this->data->messageID;
|
||||
if ($this->data->qrcId !== null) $body['qrcId'] = $this->data->qrcId;
|
||||
if ($this->data->account !== null) $body['account'] = $this->data->account;
|
||||
if ($this->data->accountDR !== null) $body['accountDR'] = $this->data->accountDR;
|
||||
if ($this->data->NewTermNo !== null) $body['NewTermNo'] = $this->data->NewTermNo;
|
||||
if ($this->data->NewMerchantId !== null) $body['NewMerchantId'] = $this->data->NewMerchantId;
|
||||
if ($this->data->redirectUrl !== null) $body['redirectUrl'] = $this->data->redirectUrl;
|
||||
if ($this->data->paymentPageUrl !== null) $body['paymentPageUrl'] = $this->data->paymentPageUrl;
|
||||
if ($this->data->fraudScore !== null) $body['fraudScore'] = $this->data->fraudScore;
|
||||
if ($this->data->messageID !== null) {
|
||||
$body['messageID'] = $this->data->messageID;
|
||||
}
|
||||
if ($this->data->qrcId !== null) {
|
||||
$body['qrcId'] = $this->data->qrcId;
|
||||
}
|
||||
if ($this->data->account !== null) {
|
||||
$body['account'] = $this->data->account;
|
||||
}
|
||||
if ($this->data->accountDR !== null) {
|
||||
$body['accountDR'] = $this->data->accountDR;
|
||||
}
|
||||
if ($this->data->NewTermNo !== null) {
|
||||
$body['NewTermNo'] = $this->data->NewTermNo;
|
||||
}
|
||||
if ($this->data->NewMerchantId !== null) {
|
||||
$body['NewMerchantId'] = $this->data->NewMerchantId;
|
||||
}
|
||||
if ($this->data->redirectUrl !== null) {
|
||||
$body['redirectUrl'] = $this->data->redirectUrl;
|
||||
}
|
||||
if ($this->data->paymentPageUrl !== null) {
|
||||
$body['paymentPageUrl'] = $this->data->paymentPageUrl;
|
||||
}
|
||||
if ($this->data->fraudScore !== null) {
|
||||
$body['fraudScore'] = $this->data->fraudScore;
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
|
||||
// <BELIEF_STATE "Casting the response to a `ChangeAccForCashUniQrResponseData` DTO provides a type-safe and structured object for the result of the account change operation.">
|
||||
public function createDtoFromResponse(Response $response): ChangeAccForCashUniQrResponseData
|
||||
{
|
||||
return ChangeAccForCashUniQrResponseData::from($response->json());
|
||||
}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define the request to create a CashLink Uni QR Code.">
|
||||
@@ -46,6 +47,14 @@ class CreateCashUniQrRequest extends Request implements HasBody
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
|
||||
// <BELIEF_STATE "Casting the response to a `CreateCashUniQrResponseData` DTO provides a type-safe and structured object for the result of the QR Code creation.">
|
||||
public function createDtoFromResponse(Response $response): CreateCashUniQrResponseData
|
||||
{
|
||||
return CreateCashUniQrResponseData::from($response->json());
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <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
|
||||
@@ -55,13 +64,27 @@ class CreateCashUniQrRequest extends Request implements HasBody
|
||||
'TermNo' => $this->data->TermNo,
|
||||
];
|
||||
|
||||
if ($this->data->messageID !== null) $body['messageID'] = $this->data->messageID;
|
||||
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->qrcId !== null) $body['qrcId'] = $this->data->qrcId;
|
||||
if ($this->data->messageID !== null) {
|
||||
$body['messageID'] = $this->data->messageID;
|
||||
}
|
||||
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->qrcId !== null) {
|
||||
$body['qrcId'] = $this->data->qrcId;
|
||||
}
|
||||
|
||||
if ($this->data->notificationUrl !== null) {
|
||||
$body['queryData'] = ['notificationUrl' => $this->data->notificationUrl];
|
||||
@@ -70,12 +93,4 @@ class CreateCashUniQrRequest extends Request implements HasBody
|
||||
return $body;
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
|
||||
// <BELIEF_STATE "Casting the response to a `CreateCashUniQrResponseData` DTO provides a type-safe and structured object for the result of the QR Code creation.">
|
||||
public function createDtoFromResponse(Response $response): CreateCashUniQrResponseData
|
||||
{
|
||||
return CreateCashUniQrResponseData::from($response->json());
|
||||
}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define the request to get the status of a CashLink Uni QR Code.">
|
||||
@@ -46,6 +47,14 @@ class GetCashUniQrStatusRequest extends Request implements HasBody
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
|
||||
// <BELIEF_STATE "Casting the response to a `GetCashUniQrStatusResponseData` DTO provides a type-safe and structured object for the status of the CashLink Uni QR Code.">
|
||||
public function createDtoFromResponse(Response $response): GetCashUniQrStatusResponseData
|
||||
{
|
||||
return GetCashUniQrStatusResponseData::from($response->json());
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
|
||||
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. The `TermNo`, `uniQrId`, and `paramsId` identify the target. Optional fields like `messageID` and `payrrn` provide additional context.">
|
||||
protected function defaultBody(): array
|
||||
@@ -57,18 +66,14 @@ class GetCashUniQrStatusRequest extends Request implements HasBody
|
||||
'paramsId' => $this->data->paramsId,
|
||||
];
|
||||
|
||||
if ($this->data->messageID !== null) $body['messageID'] = $this->data->messageID;
|
||||
if ($this->data->payrrn !== null) $body['payrrn'] = $this->data->payrrn;
|
||||
if ($this->data->messageID !== null) {
|
||||
$body['messageID'] = $this->data->messageID;
|
||||
}
|
||||
if ($this->data->payrrn !== null) {
|
||||
$body['payrrn'] = $this->data->payrrn;
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
|
||||
// <BELIEF_STATE "Casting the response to a `GetCashUniQrStatusResponseData` DTO provides a type-safe and structured object for the status of the CashLink Uni QR Code.">
|
||||
public function createDtoFromResponse(Response $response): GetCashUniQrStatusResponseData
|
||||
{
|
||||
return GetCashUniQrStatusResponseData::from($response->json());
|
||||
}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
@@ -27,6 +27,11 @@ class CreateUniQrRequest extends Request implements HasBody
|
||||
return '';
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): UniQrResponseData
|
||||
{
|
||||
return UniQrResponseData::from($response->json());
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
$body = [
|
||||
@@ -35,31 +40,52 @@ class CreateUniQrRequest extends Request implements HasBody
|
||||
'uniQrType' => $this->data->uniQrType,
|
||||
];
|
||||
|
||||
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;
|
||||
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 ($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)) {
|
||||
if (! empty($queryData)) {
|
||||
$body['queryData'] = $queryData;
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): UniQrResponseData
|
||||
{
|
||||
return UniQrResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,14 @@ class GetUniQrStatusRequest extends Request implements HasBody
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
|
||||
// <BELIEF_STATE "Casting the response to a `GetUniQrStatusResponseData` DTO provides a type-safe and structured object for the status of Universal QR Codes.">
|
||||
public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\DigitalRuble\GetUniQrStatusResponseData
|
||||
{
|
||||
return \Apoloz\AlfaBank\Sbp\Data\DigitalRuble\GetUniQrStatusResponseData::from($response->json());
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
|
||||
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. The `TermNo` and `uniQrIds` are included in the body to identify the targets.">
|
||||
protected function defaultBody(): array
|
||||
@@ -58,12 +66,4 @@ class GetUniQrStatusRequest extends Request implements HasBody
|
||||
];
|
||||
}
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
|
||||
// <BELIEF_STATE "Casting the response to a `GetUniQrStatusResponseData` DTO provides a type-safe and structured object for the status of Universal QR Codes.">
|
||||
public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\DigitalRuble\GetUniQrStatusResponseData
|
||||
{
|
||||
return \Apoloz\AlfaBank\Sbp\Data\DigitalRuble\GetUniQrStatusResponseData::from($response->json());
|
||||
}
|
||||
// </SECTION>
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Apoloz\AlfaBank\Sbp\Requests\DigitalRuble\Notifications;
|
||||
// <BELIEF_STATE "This utility uses the `PaymentDrNotificationData` DTO to structure the incoming data. The Laravel `Request` class is typically used for obtaining raw input in a web context.">
|
||||
use Apoloz\AlfaBank\Sbp\Data\DigitalRuble\Notifications\PaymentDrNotificationData;
|
||||
use Illuminate\Http\Request; // Assuming this is used to get the raw incoming data, not directly as a Saloon Request.
|
||||
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define a utility class for parsing Digital Ruble payment notifications.">
|
||||
|
||||
Reference in New Issue
Block a user