Skip to content

Commit cdd0fb6

Browse files
committed
Merge branch 'release/1.2.3'
2 parents dd14ca3 + 9baf329 commit cdd0fb6

35 files changed

+260
-213
lines changed

src/Rest/Common/Mappers.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ public static function snapshotTicker(array $snap): array
9292
return $snap;
9393
}
9494

95+
/**
96+
* @param array $snap
97+
*
98+
* @return array
99+
*/
100+
public static function snapshotTickerV2(array $snap): array
101+
{
102+
$snap['day'] = Mappers::snapshotAgg($snap['day']);
103+
$snap['lastQuote'] = Mappers::snapshotQuote($snap['lastQuote']);
104+
$snap['min'] = Mappers::snapshotAgg($snap['min']);
105+
$snap['prevDay'] = Mappers::snapshotAgg($snap['prevDay']);
106+
107+
return $snap;
108+
}
109+
95110
/**
96111
* @param array $snap
97112
*

src/Rest/Crypto/SnapshotSingleTickerFullBook.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@ public function get($tickerSymbol): array
2727
protected function mapper(array $response): array
2828
{
2929
if (array_key_exists('asks', $response['data'])) {
30-
$response['data']['asks'] = array_merge(
30+
$response['data']['asks'] = array_map(
3131
function ($ask) {
3232
return Mappers::cryptoSnapshotBookItem($ask);
3333
},
3434
$response['data']['asks']
3535
);
3636
}
37+
3738
if (array_key_exists('bids', $response['data'])) {
38-
$response['data']['bids'] = array_merge(
39+
$response['data']['bids'] = array_map(
3940
function ($bid) {
4041
return Mappers::cryptoSnapshotBookItem($bid);
4142
},

src/Rest/Forex/Aggregates.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Aggregates extends RestResource
2424
*
2525
* @throws \GuzzleHttp\Exception\GuzzleException
2626
*/
27-
public function get($tickerSymbol, $multiplier, $from, $to, $timespan = 'days', $params = []): array
27+
public function get($tickerSymbol, $multiplier, $from, $to, $timespan = 'day', $params = []): array
2828
{
2929
return $this->_get('/v2/aggs/ticker/' . $tickerSymbol . '/range/' . $multiplier . '/' . $timespan . '/' . $from . '/' . $to, $params);
3030
}

src/Rest/Forex/GroupedDaily.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class GroupedDaily extends RestResource
2323
*
2424
* @throws \GuzzleHttp\Exception\GuzzleException
2525
*/
26-
public function get($date, $locale = 'US', $market = 'FX', $params = []): array
26+
public function get($date, $locale = 'us', $market = 'fx', $params = []): array
2727
{
2828
return $this->_get('/v2/aggs/grouped/locale/' . $locale . '/market/' . $market . '/' . $date, $params);
2929
}

src/Rest/Forex/SnapshotAllTickers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function mapper(array $response): array
3131
{
3232
$response['tickers'] = array_map(
3333
function ($ticker) {
34-
return Mappers::snapshotTicker($ticker);
34+
return Mappers::snapshotTickerV2($ticker);
3535
},
3636
$response['tickers']
3737
);

src/Rest/Forex/SnapshotGainersLosers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function mapper(array $response): array
3333
{
3434
$response['tickers'] = array_map(
3535
function ($ticker) {
36-
return Mappers::snapshotTicker($ticker);
36+
return Mappers::snapshotTickerV2($ticker);
3737
},
3838
$response['tickers']
3939
);

src/Rest/Reference/TickerNews.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Class TickerNews
99
*
1010
* @package PolygonIO\rest\reference
11+
* @deprecated
1112
*/
1213
class TickerNews extends RestResource
1314
{

src/Rest/Reference/Tickers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Class Tickers
99
*
1010
* @package PolygonIO\rest\reference
11+
* @deprecated
1112
*/
1213
class Tickers extends RestResource
1314
{

tests/Rest/Crypto/SnapshotSingleTickerFullBookTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
use PHPUnit\Framework\TestCase;
66
use PolygonIO\Rest\Crypto\SnapshotSingleTickerFullBook;
7+
use PolygonIO\Tests\Concerns\LoadsStub;
78
use PolygonIO\Tests\Helpers\MocksHttp;
89

910
class SnapshotSingleTickerFullBookTest extends TestCase
1011
{
1112
use MocksHttp;
13+
use LoadsStub;
1214

1315
public function testSnapshotSingleTickerFullbookGetCall()
1416
{
@@ -18,14 +20,12 @@ public function testSnapshotSingleTickerFullbookGetCall()
1820
= new SnapshotSingleTickerFullBook('fake-api-key');
1921

2022
$snapshotSingleTickerFullBook->httpClient = $this->getHttpMock(
21-
$requestsContainer, [
22-
'data' => [],
23-
]
23+
$requestsContainer, $this->loadJsonStubFile('api/v2/snapshot/locale/global/markets/crypto/tickers/X:BTCUSD/book.json')
2424
);
2525

26-
$snapshotSingleTickerFullBook->get('BTC-ETH');
26+
$snapshotSingleTickerFullBook->get('X:BTCUSD');
2727

2828
$this->assertPath($requestsContainer,
29-
'/v2/snapshot/locale/global/markets/crypto/tickers/BTC-ETH/book');
29+
'/v2/snapshot/locale/global/markets/crypto/tickers/X:BTCUSD/book');
3030
}
3131
}

tests/Rest/Crypto/SnapshotSingleTickerTest.php

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
namespace PolygonIO\Tests\Rest\Crypto;
44

55
use PolygonIO\Rest\Crypto\SnapshotSingleTicker;
6+
use PolygonIO\Tests\Concerns\LoadsStub;
67
use PolygonIO\Tests\Helpers\MocksHttp;
78

89
class SnapshotSingleTickerTest extends \PHPUnit\Framework\TestCase
910
{
1011
use MocksHttp;
12+
use LoadsStub;
1113

1214
public function testSnapshotSingleTickerGetCall()
1315
{
@@ -16,42 +18,11 @@ public function testSnapshotSingleTickerGetCall()
1618
$singleTicker = new SnapshotSingleTicker('fake-api-key');
1719

1820
$singleTicker->httpClient = $this->getHttpMock(
19-
$requestsContainer, [
20-
'ticker' => [
21-
'day' => [
22-
'c' => 'c',
23-
'h' => 'h',
24-
'l' => 'l',
25-
'o' => 'o',
26-
'v' => 'v',
27-
],
28-
'lastTrade' => [
29-
'p' => 'p',
30-
's' => 's',
31-
'x' => 'x',
32-
'c' => 'c',
33-
't' => 't',
34-
],
35-
'min' => [
36-
'c' => 'c',
37-
'h' => 'h',
38-
'l' => 'l',
39-
'o' => 'o',
40-
'v' => 'v',
41-
],
42-
'prevDay' => [
43-
'c' => 'c',
44-
'h' => 'h',
45-
'l' => 'l',
46-
'o' => 'o',
47-
'v' => 'v',
48-
],
49-
],
50-
]
21+
$requestsContainer, $this->loadJsonStubFile('api/v2/snapshot/locale/global/markets/crypto/tickers/X:BTCUSD.json')
5122
);
5223

53-
$singleTicker->get('BTC-ETH');
24+
$singleTicker->get('X:BTCUSD');
5425

55-
$this->assertPath($requestsContainer, '/v2/snapshot/locale/global/markets/crypto/tickers/BTC-ETH');
26+
$this->assertPath($requestsContainer, '/v2/snapshot/locale/global/markets/crypto/tickers/X:BTCUSD');
5627
}
5728
}

0 commit comments

Comments
 (0)