/** * Obtain multiple Block resources for the given identifiers (hash or height). * * @param string[] $array * @param array $params Parameters. Options: txstart, and limit * @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 Block[] */ public function getMultiple($array, $params = array(), $apiContext = null, $restCall = null) { ArgumentArrayValidator::validate($array, 'array'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array('txstart' => 1, 'limit' => 1); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $blockList = implode(";", $array); $payLoad = ""; $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall("{$chainUrlPrefix}/blocks/{$blockList}?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall); return Block::getList($json); }
/** * @return Block[] */ public function testGetMultiple() { $request = $this->operation['response']['body']; $blockArray = Block::getList($request); $blockList = array(); /** @var Block $block */ foreach ($blockArray as $block) { $blockList[] = $block->getHash(); } $result = Block::getMultiple($blockList, array(), $this->apiContext, $this->mockBlockCypherRestCall); $this->assertNotNull($result); $this->assertContainsOnlyInstancesOf('\\BlockCypher\\Api\\Block', $result); $this->assertEquals(count($result), count($blockList)); foreach ($result as $resultBlock) { $this->assertContains($resultBlock->getHash(), $blockList); } return $result; }