diff --git a/src/External/Api/TransactionQuery.php b/src/External/Api/TransactionQuery.php index 08659160b..39a1b36eb 100644 --- a/src/External/Api/TransactionQuery.php +++ b/src/External/Api/TransactionQuery.php @@ -5,14 +5,9 @@ namespace Bavix\Wallet\External\Api; use Bavix\Wallet\Interfaces\Wallet; -use Bavix\Wallet\Models\Transaction; -final readonly class TransactionQuery +final readonly class TransactionQuery implements TransactionQueryInterface { - public const TYPE_DEPOSIT = Transaction::TYPE_DEPOSIT; - - public const TYPE_WITHDRAW = Transaction::TYPE_WITHDRAW; - /** * @param self::TYPE_DEPOSIT|self::TYPE_WITHDRAW $type * @param array|null $meta diff --git a/src/External/Api/TransactionQueryHandler.php b/src/External/Api/TransactionQueryHandler.php index 5df4a661f..59c494a33 100644 --- a/src/External/Api/TransactionQueryHandler.php +++ b/src/External/Api/TransactionQueryHandler.php @@ -26,19 +26,19 @@ public function __construct( public function apply(array $objects): array { $wallets = $this->assistantService->getWallets( - array_map(static fn (TransactionQuery $query): Wallet => $query->getWallet(), $objects), + array_map(static fn (TransactionQueryInterface $query): Wallet => $query->getWallet(), $objects), ); $values = array_map( - fn (TransactionQuery $query) => match ($query->getType()) { - TransactionQuery::TYPE_DEPOSIT => $this->prepareService->deposit( + fn (TransactionQueryInterface $query) => match ($query->getType()) { + TransactionQueryInterface::TYPE_DEPOSIT => $this->prepareService->deposit( $query->getWallet(), $query->getAmount(), $query->getMeta(), $query->isConfirmed(), $query->getUuid(), ), - TransactionQuery::TYPE_WITHDRAW => $this->prepareService->withdraw( + TransactionQueryInterface::TYPE_WITHDRAW => $this->prepareService->withdraw( $query->getWallet(), $query->getAmount(), $query->getMeta(), diff --git a/src/External/Api/TransactionQueryHandlerInterface.php b/src/External/Api/TransactionQueryHandlerInterface.php index 5fead1dc8..7ba3ac0b3 100644 --- a/src/External/Api/TransactionQueryHandlerInterface.php +++ b/src/External/Api/TransactionQueryHandlerInterface.php @@ -17,7 +17,7 @@ interface TransactionQueryHandlerInterface * If there is a need to check the balance, then you need to wrap the method call in the AtomicServiceInterface * and check the correctness of the balance manually. * - * @param non-empty-array $objects + * @param non-empty-array $objects * * @return non-empty-array * diff --git a/src/External/Api/TransactionQueryInterface.php b/src/External/Api/TransactionQueryInterface.php new file mode 100644 index 000000000..d51dbdeb9 --- /dev/null +++ b/src/External/Api/TransactionQueryInterface.php @@ -0,0 +1,33 @@ +|null + */ + public function getMeta(): ?array; + + public function isConfirmed(): bool; + + public function getUuid(): ?string; +} diff --git a/src/External/Api/TransferQuery.php b/src/External/Api/TransferQuery.php index aeba1e501..76e0afe20 100644 --- a/src/External/Api/TransferQuery.php +++ b/src/External/Api/TransferQuery.php @@ -7,7 +7,7 @@ use Bavix\Wallet\External\Contracts\ExtraDtoInterface; use Bavix\Wallet\Interfaces\Wallet; -final readonly class TransferQuery +final readonly class TransferQuery implements TransferQueryInterface { /** * @param array|ExtraDtoInterface|null $meta diff --git a/src/External/Api/TransferQueryHandler.php b/src/External/Api/TransferQueryHandler.php index 51d72ea95..3f5a61457 100644 --- a/src/External/Api/TransferQueryHandler.php +++ b/src/External/Api/TransferQueryHandler.php @@ -27,11 +27,11 @@ public function __construct( public function apply(array $objects): array { $wallets = $this->assistantService->getWallets( - array_map(static fn (TransferQuery $query): Wallet => $query->getFrom(), $objects), + array_map(static fn (TransferQueryInterface $query): Wallet => $query->getFrom(), $objects), ); $values = array_map( - fn (TransferQuery $query) => $this->prepareService->transferLazy( + fn (TransferQueryInterface $query) => $this->prepareService->transferLazy( $query->getFrom(), $query->getTo(), Transfer::STATUS_TRANSFER, diff --git a/src/External/Api/TransferQueryHandlerInterface.php b/src/External/Api/TransferQueryHandlerInterface.php index f489a510c..095c4c78f 100644 --- a/src/External/Api/TransferQueryHandlerInterface.php +++ b/src/External/Api/TransferQueryHandlerInterface.php @@ -17,7 +17,7 @@ interface TransferQueryHandlerInterface * If there is a need to check the balance, then you need to wrap the method call in the AtomicServiceInterface * and check the correctness of the balance manually. * - * @param non-empty-array $objects + * @param non-empty-array $objects * * @return non-empty-array * diff --git a/src/External/Api/TransferQueryInterface.php b/src/External/Api/TransferQueryInterface.php new file mode 100644 index 000000000..03bae4ebf --- /dev/null +++ b/src/External/Api/TransferQueryInterface.php @@ -0,0 +1,22 @@ +|ExtraDtoInterface|null + */ + public function getMeta(): array|ExtraDtoInterface|null; +}