Skip to content

Commit

Permalink
Merge pull request #89 from bzeron/master
Browse files Browse the repository at this point in the history
update 1.1.18
  • Loading branch information
Ive20 authored Jul 20, 2020
2 parents c278f75 + 62f1759 commit 2d7c3bc
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ abstract class Api
/**
* @var string SDK Version
*/
const VERSION = '1.1.17';
const VERSION = '1.1.18';

/**
* @var string SDK update date
*/
const UPDATE_DATE = '2020.07.13';

/**
* @var string
Expand Down Expand Up @@ -136,8 +141,8 @@ public static function getLogger()
{
if (self::$logger === null) {
self::$logger = new Logger('kucoin-sdk');
$handler = new RotatingFileHandler(static::getLogPath() . '/kucoin-sdk.log', 0, static::$logLevel);
$formatter = new LineFormatter(null, null, false, true);
$handler = new RotatingFileHandler(static::getLogPath() . '/kucoin-sdk.log', 0, static::$logLevel);
$formatter = new LineFormatter(null, null, false, true);
$handler->setFormatter($formatter);
self::$logger->pushHandler($handler);
}
Expand Down Expand Up @@ -216,7 +221,7 @@ public function call($method, $uri, array $params = [], array $headers = [], $ti
$request->getRequestUri(),
$request->getBodyParams()
);
$headers = array_merge($headers, $authHeaders);
$headers = array_merge($headers, $authHeaders);
}
$headers['User-Agent'] = 'KuCoin-PHP-SDK/' . static::VERSION;

Expand All @@ -232,7 +237,7 @@ public function call($method, $uri, array $params = [], array $headers = [], $ti
static::getLogger()->debug(sprintf('Sent a HTTP request#%s: %s', $requestId, $request));
}
$requestStart = microtime(true);
$response = $this->http->request($request, $timeout);
$response = $this->http->request($request, $timeout);
if (self::isDebugMode()) {
$cost = (microtime(true) - $requestStart) * 1000;
static::getLogger()->debug(sprintf('Received a HTTP response#%s: cost %.2fms, %s', $requestId, $cost, $response));
Expand Down
14 changes: 14 additions & 0 deletions src/PublicApi/Symbol.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ public function getAtomicFullOrderBook($symbol)
return $response->getApiData();
}

/**
* Get full order book(atomic) v2
* @param string $symbol
* @return array
* @throws \KuCoin\SDK\Exceptions\BusinessException
* @throws \KuCoin\SDK\Exceptions\HttpException
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
*/
public function getV2AtomicFullOrderBook($symbol)
{
$response = $this->call(Request::METHOD_GET, '/api/v2/market/orderbook/level3', compact('symbol'));
return $response->getApiData();
}

/**
* Get trade histories
* @param string $symbol
Expand Down
17 changes: 17 additions & 0 deletions tests/SymbolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,23 @@ public function testGetAtomicFullOrderBook(Symbol $api)
$this->assertArrayHasKey('time', $data);
}

/**
* @dataProvider apiProvider
* @param Symbol $api
* @throws \KuCoin\SDK\Exceptions\BusinessException
* @throws \KuCoin\SDK\Exceptions\HttpException
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
*/
public function testGetV2AtomicFullOrderBook(Symbol $api)
{
$data = $api->getV2AtomicFullOrderBook('ETH-BTC');
$this->assertInternalType('array', $data);
$this->assertArrayHasKey('sequence', $data);
$this->assertArrayHasKey('bids', $data);
$this->assertArrayHasKey('asks', $data);
$this->assertArrayHasKey('time', $data);
}


/**
* @dataProvider apiProvider
Expand Down

0 comments on commit 2d7c3bc

Please sign in to comment.