Skip to content

Commit

Permalink
Merge pull request #116 from wanfeiyy/master
Browse files Browse the repository at this point in the history
update api
  • Loading branch information
hhxsv5 authored Dec 2, 2021
2 parents 99436ca + 162f672 commit a028178
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

</details>

Expand Down
4 changes: 2 additions & 2 deletions src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions src/PublicApi/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
23 changes: 23 additions & 0 deletions tests/PublicApi/CurrencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}

0 comments on commit a028178

Please sign in to comment.