/**
  * @param $walletName
  * @param $coinSymbol
  * @param $token
  * @return BlockCypherWallet|null
  * @throws BlockCypherConnectionException
  * @throws \Exception
  */
 public function getWallet($walletName, $coinSymbol, $token)
 {
     $apiContext = $this->apiContextFactory->getApiContext($coinSymbol, $token);
     $walletClient = new WalletClient($apiContext);
     $wallet = null;
     try {
         $wallet = $walletClient->get($walletName);
     } catch (BlockCypherConnectionException $e) {
         if ($e->getCode() == self::ERROR_WALLET_NOT_FOUND) {
             // return null
         } else {
             throw $e;
         }
     }
     return $wallet;
 }
Esempio n. 2
0
 /**
  * @dataProvider mockProviderGetParamsValidation
  * @param WalletClient $obj
  * @param PHPUnit_Framework_MockObject_MockObject|ApiContext $mockApiContext
  * @param PHPUnit_Framework_MockObject_MockObject|BlockCypherRestCall $mockBlockCypherRestCall
  * @param $params
  * @expectedException \InvalidArgumentException
  */
 public function testGetParamsValidationForParams($obj, $mockApiContext, $mockBlockCypherRestCall, $params)
 {
     $mockBlockCypherRestCall->expects($this->any())->method('execute')->will($this->returnValue(WalletTest::getJson()));
     $obj->get(WalletTest::getObject()->getName(), $params, $mockApiContext, $mockBlockCypherRestCall);
 }
Esempio n. 3
0
<?php

// Run on console:
// php -f .\sample\wallet-api\GetWalletEndpoint.php
require __DIR__ . '/../bootstrap.php';
use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Client\WalletClient;
use BlockCypher\Rest\ApiContext;
$apiContext = ApiContext::create('main', 'btc', 'v1', new SimpleTokenCredential('c0afcccdde5081d6429de37d16166ead'), array('mode' => 'sandbox', 'log.LogEnabled' => true, 'log.FileName' => 'BlockCypher.log', 'log.LogLevel' => 'DEBUG'));
$walletClient = new WalletClient($apiContext);
$wallet = $walletClient->get('alice');
ResultPrinter::printResult("Get a Wallet", "Wallet", $wallet->getName(), null, $wallet);