Skip to content
This repository has been archived by the owner on Oct 24, 2020. It is now read-only.

Commit

Permalink
Close #18. Added Feature Endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Celano, Jose committed Jun 19, 2016
1 parent 8d38fcd commit 17e6319
Show file tree
Hide file tree
Showing 7 changed files with 436 additions and 1,860 deletions.
31 changes: 31 additions & 0 deletions lib/BlockCypher/Client/BlockchainClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,35 @@ public function get($name, $params = array(), $apiContext = null, $restCall = nu
$ret->fromJson($json);
return $ret;
}

/**
* Obtain the information about the adoption of upgrade features on a blockchain.
*
* @param string $featureName
* @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 string
*/
public function getFeature($featureName, $params = array(), $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($featureName, 'featureName');
ArgumentGetParamsValidator::validate($params, 'params');
$allowedParams = array();
$params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);

$payLoad = "";

$chainUrlPrefix = $this->getChainUrlPrefix($apiContext);

$json = $this->executeCall(
"$chainUrlPrefix/feature/$featureName?" . http_build_query($params),
"GET",
$payLoad,
null,
$apiContext,
$restCall
);
return $json;
}
}
4 changes: 4 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
BlockCypher PHP SDK release notes
=================================

v1.4.0
------
* Close #18. Added Feature Endpoint.

v1.3.1
------
* Fix #12. Added missing allowed params in GET params validation.
Expand Down
18 changes: 18 additions & 0 deletions sample/chain-api/GetFeature.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

// # Get Blockchain Feature Status
//
// API called: '/v1/btc/main/feature/$NAME'

require __DIR__ . '/../bootstrap.php';

$blockchainClient = new \BlockCypher\Client\BlockchainClient($apiContexts['BTC.main']);

try {
$feature = $blockchainClient->getFeature('bip65');
} catch (Exception $ex) {
ResultPrinter::printError("Get Feature", "", "", null, $ex);
exit(1);
}

ResultPrinter::printResult("Get Feature", "", "", null, $feature);
Loading

0 comments on commit 17e6319

Please sign in to comment.