forked from apoloz/alfa-bank-sdk
64 lines
1.8 KiB
PHP
64 lines
1.8 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace Apoloz\AlfaBank\Requests\NominalAccounts\Identification;
|
||
|
||
use Apoloz\AlfaBank\Data\NominalAccounts\Identification\UnidentifiedTransactionData;
|
||
use Saloon\Contracts\Body\HasBody;
|
||
use Saloon\Enums\Method;
|
||
use Saloon\Http\Request;
|
||
use Saloon\Http\Response;
|
||
use Saloon\Traits\Body\HasJsonBody;
|
||
|
||
class CreateUnidentifiedTransactionRequest extends Request implements HasBody
|
||
{
|
||
use HasJsonBody;
|
||
|
||
protected Method $method = Method::POST;
|
||
|
||
public function __construct(
|
||
protected string $documentNumber,
|
||
protected string $date,
|
||
protected float $amount,
|
||
protected string $purpose,
|
||
protected string $accountNumber,
|
||
protected ?array $payer = null,
|
||
) {}
|
||
|
||
public function resolveEndpoint(): string
|
||
{
|
||
return '/api/na/jp/v1/unidentified-transactions';
|
||
}
|
||
|
||
public function createDtoFromResponse(Response $response): UnidentifiedTransactionData
|
||
{
|
||
return UnidentifiedTransactionData::from($response->json());
|
||
}
|
||
|
||
protected function defaultBody(): array
|
||
{
|
||
return array_filter([
|
||
'documentNumber' => $this->documentNumber,
|
||
'date' => $this->date,
|
||
'amount' => $this->amount,
|
||
'purpose' => $this->purpose,
|
||
'accountNumber' => $this->accountNumber,
|
||
'payer' => $this->payer ?? $this->getDefaultPayer(),
|
||
], fn ($value) => $value !== null);
|
||
}
|
||
|
||
protected function getDefaultPayer(): array
|
||
{
|
||
return [
|
||
'inn' => '221284672706',
|
||
'kpp' => '641914992',
|
||
'accountNumber' => '87149728127096890679',
|
||
'name' => 'Тестовый плательщик',
|
||
'bankAccount' => '3932755239052037086628',
|
||
'bankBik' => '108997635',
|
||
'bankName' => 'АО "Альфа-Банк"',
|
||
];
|
||
}
|
||
}
|