diff --git a/README.md b/README.md index e948305..b47be3c 100644 --- a/README.md +++ b/README.md @@ -318,6 +318,7 @@ go(function () { | KuCoin\SDK\PublicApi\Currency::getList() | NO | https://docs.kucoin.com/#get-currencies | | KuCoin\SDK\PublicApi\Currency::getDetail() | NO | https://docs.kucoin.com/#get-currency-detail | | KuCoin\SDK\PublicApi\Currency::getPrices() | NO | https://docs.kucoin.com/#get-fiat-price | +| KuCoin\SDK\PublicApi\Currency::getV2Detail() | NO | https://docs.kucoin.com/#get-currency-detail-recommend | diff --git a/src/Api.php b/src/Api.php index 521033f..6cb1b21 100644 --- a/src/Api.php +++ b/src/Api.php @@ -16,12 +16,12 @@ abstract class Api /** * @var string SDK Version */ - const VERSION = '1.1.23'; + const VERSION = '1.1.24'; /** * @var string SDK update date */ - const UPDATE_DATE = '2021.10.25'; + const UPDATE_DATE = '2021.12.02'; /** * @var string diff --git a/src/PublicApi/Currency.php b/src/PublicApi/Currency.php index c7ebbca..24a3e5d 100644 --- a/src/PublicApi/Currency.php +++ b/src/PublicApi/Currency.php @@ -54,4 +54,20 @@ public function getPrices($base = null, $currencies = null) $response = $this->call(Request::METHOD_GET, '/api/v1/prices', compact('base', 'currencies')); return $response->getApiData(); } + + /** + * Get the v2 details of a currency + * + * @param $currency + * @param null $chain + * @return mixed|null + * @throws \KuCoin\SDK\Exceptions\BusinessException + * @throws \KuCoin\SDK\Exceptions\HttpException + * @throws \KuCoin\SDK\Exceptions\InvalidApiUriException + */ + public function getV2Detail($currency, $chain = null) + { + $response = $this->call(Request::METHOD_GET, '/api/v2/currencies/' . $currency, compact('chain')); + return $response->getApiData(); + } } \ No newline at end of file diff --git a/tests/PublicApi/CurrencyTest.php b/tests/PublicApi/CurrencyTest.php index f4172fe..d9e8a19 100644 --- a/tests/PublicApi/CurrencyTest.php +++ b/tests/PublicApi/CurrencyTest.php @@ -65,4 +65,27 @@ public function testGetPrices(Currency $api) $this->assertInternalType('array', $prices); $this->assertNotEmpty($prices); } + + /** + * @dataProvider apiProvider + * @param Currency $api + * @throws \KuCoin\SDK\Exceptions\BusinessException + * @throws \KuCoin\SDK\Exceptions\HttpException + * @throws \KuCoin\SDK\Exceptions\InvalidApiUriException + */ + public function testGetV2Detail(Currency $api) + { + $currency = $api->getV2Detail('BTC'); + $this->assertInternalType('array', $currency); + $this->assertArrayHasKey('currency', $currency); + $this->assertArrayHasKey('name', $currency); + $this->assertArrayHasKey('fullName', $currency); + $this->assertArrayHasKey('precision', $currency); + $this->assertArrayHasKey('confirms', $currency); + $this->assertArrayHasKey('contractAddress', $currency); + $this->assertArrayHasKey('isMarginEnabled', $currency); + $this->assertArrayHasKey('isDebitEnabled', $currency); + $this->assertArrayHasKey('chains', $currency); + $this->assertInternalType('array', $currency['chains']); + } } \ No newline at end of file