/** * @param Wallet $wallet * @param BigMoney|null $balance * @param $apiUrl * @return WalletListItemDto */ public static function from(Wallet $wallet, BigMoney $balance, $apiUrl) { $walletListItemDto = new self(); $walletListItemDto->setId($wallet->getId()->getValue()); $walletListItemDto->setCoinSymbol($wallet->getCoinSymbol()); $walletListItemDto->setCreationTime($wallet->getCreationTime()); $walletListItemDto->setName($wallet->getName()); if ($balance !== null) { $walletListItemDto->setBalance((double) (string) $balance->getAmount()); } else { $walletListItemDto->setBalance(-1); } $walletListItemDto->setApiUrl($apiUrl); return $walletListItemDto; }
/** * @param Wallet $wallet * @param Transaction[]|null $transactions * @param BlockCypherAddress $blockCypherAddress * @param ApiRouter $apiRouter * @param ExplorerRouter $explorerRouter * @return TransactionListDto */ public static function from(Wallet $wallet, $transactions, BlockCypherAddress $blockCypherAddress, ApiRouter $apiRouter, ExplorerRouter $explorerRouter) { $transactionListDto = new self(); // From BlockCypher Address $transactionListDto->setTotalSent($blockCypherAddress->getTotalSent()); $transactionListDto->setTotalReceived($blockCypherAddress->getTotalReceived()); $transactionListDto->setUnconfirmedBalance($blockCypherAddress->getUnconfirmedBalance()); $transactionListDto->setBalance($blockCypherAddress->getBalance()); $transactionListDto->setFinalBalance($blockCypherAddress->getFinalBalance()); $transactionListDto->setNTx($blockCypherAddress->getNTx()); $transactionListDto->setUnconfirmedNTx($blockCypherAddress->getUnconfirmedNTx()); $transactionListDto->setFinalNTx($blockCypherAddress->getFinalNTx()); $blockCypherTXRefs = $blockCypherAddress->getAllTxrefs(); // Confirmed and unconfirmed $transactionListItems = TransactionListItemArray::from($blockCypherTXRefs); $transactionListItemDtos = TransactionListItemDtoArray::from($wallet, $transactions, $transactionListItems, $apiRouter, $explorerRouter); $transactionListDto->setTransactionListItemDtos($transactionListItemDtos); return $transactionListDto; }