Пример #1
0
 /**
  * Allow to embed small pieces of data on the blockchain.
  *
  * @param NullData $nullData
  * @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 NullData
  */
 public function create(NullData $nullData, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentGetParamsValidator::validate($params, 'params');
     $allowedParams = array();
     $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     $payLoad = $nullData->toJSON();
     $chainUrlPrefix = self::getChainUrlPrefix($apiContext);
     $json = self::executeCall("{$chainUrlPrefix}/txs/data?" . http_build_query($params), "POST", $payLoad, null, $apiContext, $restCall);
     $nullData->fromJson($json);
     return $nullData;
 }
Пример #2
0
 /**
  * @dataProvider mockProvider
  * @param NullData $obj
  */
 public function testCreate($obj, $mockApiContext)
 {
     $mockBlockCypherRestCall = $this->getMockBuilder('\\BlockCypher\\Transport\\BlockCypherRestCall')->disableOriginalConstructor()->getMock();
     $mockBlockCypherRestCall->expects($this->any())->method('execute')->will($this->returnValue(self::getJson()));
     $result = $obj->create(array(), $mockApiContext, $mockBlockCypherRestCall);
     $this->assertNotNull($result);
 }