/** * @depends testGet * @param $webHook WebHook * @return WebHook[] */ public function testGetAll($webHook) { $result = WebHook::getAll(array(), $this->apiContext, $this->mockBlockCypherRestCall); $this->assertNotNull($result); $found = false; $foundObject = null; foreach ($result as $webHookObject) { if ($webHookObject->getId() == $webHook->getId()) { $found = true; $foundObject = $webHookObject; break; } } $this->assertTrue($found, "The Created WebHook was not found in the get list"); $this->assertEquals($webHook->getId(), $foundObject->getId()); return $result; }
/** * Create a new WebHook. * * @param WebHook $webHook * @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 WebHook */ public function create(WebHook $webHook, $apiContext = null, $restCall = null) { $payLoad = $webHook->toJSON(); $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall("{$chainUrlPrefix}/hooks", "POST", $payLoad, null, $apiContext, $restCall); $webHook->fromJson($json); return $webHook; }
/** * Obtain all WebHook resources for the provided token. * * @deprecated since version 1.2. Use WebHookClient. * @param array $params Parameters. Options: token * @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 WebHook[] */ public static function getAll($params = array(), $apiContext = null, $restCall = null) { ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array('token' => 1); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = ""; $chainUrlPrefix = self::getChainUrlPrefix($apiContext); $json = self::executeCall("{$chainUrlPrefix}/hooks?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall); return WebHook::getList($json); }
/** * @dataProvider mockProvider * @param WebHook $obj */ public function testDelete($obj, $mockApiContext) { $mockBlockCypherRestCall = $this->getMockBuilder('\\BlockCypher\\Transport\\BlockCypherRestCall')->disableOriginalConstructor()->getMock(); $mockBlockCypherRestCall->expects($this->any())->method('execute')->will($this->returnValue(true)); $result = $obj->delete($mockApiContext, $mockBlockCypherRestCall); $this->assertNotNull($result); }