/** * @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; }
/** * @test * @dataProvider invalidGetCurrencyAbbrevProvider * @expectedException \BlockCypher\Exception\BlockCypherConfigurationException * @param mixed $coinSymbol * @throws \BlockCypher\Exception\BlockCypherConfigurationException */ public function testGetCurrencyAbbrevInvalidInput($coinSymbol) { BlockCypherCoinSymbolConstants::getCurrencyAbbrev($coinSymbol); }
/** * @param string $coinSymbol * @return string */ public function coinSymbolToCurrencyNameFilter($coinSymbol) { return BlockCypherCoinSymbolConstants::getCurrencyAbbrev($coinSymbol); }