/**
  * @dataProvider mockProvider
  * @param AddressBalance $obj
  */
 public function testGet($obj, $mockApiContext)
 {
     $mockBlockCypherRestCall = $this->getMockBuilder('\\BlockCypher\\Transport\\BlockCypherRestCall')->disableOriginalConstructor()->getMock();
     $mockBlockCypherRestCall->expects($this->any())->method('execute')->will($this->returnValue(WalletBalanceAsAddressBalanceTest::getJson()));
     /** @noinspection PhpParamsInspection */
     $result = $obj->get("alice", array(), $mockApiContext, $mockBlockCypherRestCall);
     $this->assertNotNull($result);
     $this->assertInstanceOf('BlockCypher\\Api\\AddressBalance', $result);
 }
 /**
  * @param Address $address
  * @param BlockCypherAddressBalance $blockCypherAddressBalance
  * @param string $apiUrl
  * @param string $explorerUrl
  * @return $this
  */
 public static function from(Address $address, BlockCypherAddressBalance $blockCypherAddressBalance, $apiUrl, $explorerUrl)
 {
     $addressListItemDto = new self();
     $addressListItemDto->setAddress($address->getAddress());
     $addressListItemDto->setTag($address->getTag());
     $addressListItemDto->setCreationTime($address->getCreationTime());
     $addressListItemDto->setFinalBalance($blockCypherAddressBalance->getFinalBalance());
     $addressListItemDto->setNTx($blockCypherAddressBalance->getNTx());
     $addressListItemDto->setApiUrl($apiUrl);
     $addressListItemDto->setExplorerUrl($explorerUrl);
     return $addressListItemDto;
 }
示例#3
0
 /**
  * Obtain multiple AddressBalances resources for the given identifiers.
  *
  * @deprecated since version 1.2. Use AddressClient.
  * @param string[] $array
  * @param array $params Parameters
  * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
  * @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls
  * @return AddressBalance[]
  */
 public static function getMultiple($array, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentArrayValidator::validate($array, 'array');
     ArgumentGetParamsValidator::validate($params, 'params');
     $allowedParams = array();
     $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     $payLoad = "";
     $addressList = implode(";", $array);
     $chainUrlPrefix = self::getChainUrlPrefix($apiContext);
     $json = self::executeCall("{$chainUrlPrefix}/addrs/{$addressList}/balance" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall);
     return AddressBalance::getList($json);
 }
 /**
  * @return AddressBalance[]
  */
 public function testGetMultiple()
 {
     $request = $this->operation['response']['body'];
     $addressArray = AddressBalance::getList($request);
     $addressList = array();
     /** @var AddressBalance $address */
     foreach ($addressArray as $address) {
         $addressList[] = $address->getAddress();
     }
     $result = AddressBalance::getMultiple($addressList, array(), $this->apiContext, $this->mockBlockCypherRestCall);
     $this->assertNotNull($result);
     $this->assertContainsOnlyInstancesOf('\\BlockCypher\\Api\\AddressBalance', $result);
     $this->assertEquals(count($result), count($addressList));
     foreach ($result as $addr) {
         $this->assertContains($addr->getAddress(), $addressList);
     }
     return $result;
 }
示例#5
0
 /**
  * @dataProvider mockProviderGetParamsValidation
  * @param AddressBalance $obj
  * @param $mockApiContext
  * @param $params
  * @expectedException \InvalidArgumentException
  */
 public function testGetMultipleParamsValidationForParams($obj, $mockApiContext, $params)
 {
     $mockBlockCypherRestCall = $this->getMockBuilder('\\BlockCypher\\Transport\\BlockCypherRestCall')->disableOriginalConstructor()->getMock();
     $mockBlockCypherRestCall->expects($this->any())->method('execute')->will($this->returnValue('[' . AddressBalanceTest::getJson() . ']'));
     $addressBalanceList = array(AddressBalanceTest::getObject()->getAddress());
     /** @noinspection PhpUndefinedVariableInspection */
     /** @noinspection PhpParamsInspection */
     $obj->getMultiple($addressBalanceList, $params, $mockApiContext, $mockBlockCypherRestCall);
 }
示例#6
0
 /**
  * Obtain the AddressBalance resource for the given address.
  *
  * @deprecated since version 1.2. Use AddressClient.
  * @param string $address
  * @param array $params Parameters
  * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
  * @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls
  * @return AddressBalance
  */
 public static function getOnlyBalance($address, $params = array(), $apiContext = null, $restCall = null)
 {
     return AddressBalance::get($address, $params, $apiContext, $restCall);
 }
 /**
  * @return AddressBalance
  */
 public function testGetOnlyBalance()
 {
     $request = $this->operation['response']['body'];
     $addressBalance = new AddressBalance($request);
     $result = Address::getOnlyBalance($addressBalance->getAddress(), array(), $this->apiContext, $this->mockBlockCypherRestCall);
     $this->assertNotNull($result);
     $this->assertInstanceOf('\\BlockCypher\\Api\\AddressBalance', $result);
     // Assert only immutable values.
     $this->assertEquals($addressBalance->getAddress(), $result->getAddress());
     return $result;
 }