/**
  * @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 $walletName
  * @param $coinSymbol
  * @param $token
  * @return BigMoney|null
  * @throws BlockCypherConnectionException
  * @throws \BlockCypher\Exception\BlockCypherConfigurationException
  * @throws \Exception
  */
 public function getWalletFinalBalance($walletName, $coinSymbol, $token)
 {
     $apiContext = $this->apiContextFactory->getApiContext($coinSymbol, $token);
     $addressClient = new AddressClient($apiContext);
     $balance = null;
     $address = null;
     try {
         $address = $addressClient->get($walletName);
     } catch (BlockCypherConnectionException $e) {
         if ($e->getCode() == self::ERROR_WALLET_NOT_FOUND) {
             // return null
         } else {
             throw $e;
         }
     }
     if ($address !== null) {
         $currencyAbbrev = BlockCypherCoinSymbolConstants::getCurrencyAbbrev($coinSymbol);
         $currency = new Currency($currencyAbbrev);
         $balance = BigMoney::fromInteger($address->getFinalBalance(), $currency);
     }
     return $balance;
 }