Skip to content

Commit dd14ca3

Browse files
Merge branch 'release/1.2.2'
2 parents d311f11 + 3b09f8f commit dd14ca3

File tree

61 files changed

+1721
-42
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1721
-42
lines changed

src/Rest/Crypto/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 = [])
27+
public function get($tickerSymbol, $multiplier, $from, $to, $timespan = 'day', $params = [])
2828
{
2929
return $this->_get('/v2/aggs/ticker/' . $tickerSymbol . '/range/' . $multiplier . '/' . $timespan . '/' . $from . '/' . $to, $params);
3030
}

src/Rest/Crypto/DailyOpenClose.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace PolygonIO\Rest\Crypto;
44

5-
use PolygonIO\Rest\Common\Mappers;
65
use PolygonIO\Rest\RestResource;
6+
use \PolygonIO\Rest\Common\Mappers;
77

88
/**
99
* Class DailyOpenClose
@@ -35,11 +35,15 @@ public function get($from, $to, $date): array
3535
protected function mapper(array $response): array
3636
{
3737
if (array_key_exists('openTrades', $response)) {
38-
$response['openTrades'] = array_map(Mappers::cryptoTick, $response['openTrades']);
38+
$response['openTrades'] = array_map(function($ticker) {
39+
return Mappers::cryptoTick($ticker);
40+
}, $response['openTrades']);
3941
}
4042

4143
if (array_key_exists('closingTrades', $response)) {
42-
$response['closingTrades'] = array_map(Mappers::cryptoTick, $response['closingTrades']);
44+
$response['closingTrades'] = array_map(function ($ticker) {
45+
return Mappers::cryptoTick($ticker);
46+
}, $response['closingTrades']);
4347
}
4448

4549
return $response;

src/Rest/Crypto/GroupedDaily.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@ class GroupedDaily extends RestResource
1515

1616
/**
1717
* @param $date
18-
* @param string $locale
19-
* @param string $market
2018
* @param array $params
2119
*
2220
* @return array
2321
*
2422
* @throws \GuzzleHttp\Exception\GuzzleException
2523
*/
26-
public function get($date, $locale = 'US', $market = 'CRYPTO', $params = []): array
24+
public function get($date, array $params = []): array
2725
{
28-
return $this->_get('/v2/aggs/grouped/locale/' . $locale . '/market/' . $market . '/' . $date, $params);
26+
return $this->_get('/v2/aggs/grouped/locale/global/market/crypto/' . $date, $params);
2927
}
3028

3129
/**

src/Rest/Crypto/SnapshotGainersLosers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class SnapshotGainersLosers extends RestResource
2020
*
2121
* @throws \GuzzleHttp\Exception\GuzzleException
2222
*/
23-
public function get($direction = 'gainers'): array
23+
public function get(string $direction = 'gainers'): array
2424
{
2525
return $this->_get('/v2/snapshot/locale/global/markets/crypto/' . $direction);
2626
}
@@ -34,7 +34,7 @@ protected function mapper(array $response): array
3434
{
3535
$response['tickers'] = array_map(
3636
function ($ticker) {
37-
return Mappers::snapshotTicker($ticker);
37+
return Mappers::snapshotCryptoTicker($ticker);
3838
},
3939
$response['tickers']
4040
);

tests/Rest/Crypto/AggregatesTest.php

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

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

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

1315
public function testAggregatesCloseGetCall()
1416
{
1517
$requestsContainer = [];
1618

1719
$previousClose = new Aggregates('fake-api-key');
1820
$previousClose->httpClient = $this->getHttpMock(
19-
$requestsContainer, [
20-
'results' => [],
21-
]
21+
$requestsContainer, $this->loadJsonStubFile('api/v2/aggs/ticker/AAPL/range/1/day/2020-10-14/2020-10-15.json')
2222
);
2323

24-
$previousClose->get('AAPL', 1, '2018-2-2', '2019-2-2');
24+
$previousClose->get('AAPL', 1, '2020-10-14', '2020-10-15');
2525

26-
$this->assertPath($requestsContainer, '/v2/aggs/ticker/AAPL/range/1/days/2018-2-2/2019-2-2');
26+
$this->assertPath($requestsContainer, '/v2/aggs/ticker/AAPL/range/1/day/2020-10-14/2020-10-15');
2727
}
2828
}

tests/Rest/Crypto/CryptoExchangesTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
33
namespace PolygonIO\Tests\Rest\Crypto;
44

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

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

1214
public function testCryptoExchangesGetCall()
1315
{
1416
$requestsContainer = [];
1517

1618
$cryptoExchanges = new CryptoExchanges('fake-api-key');
17-
$cryptoExchanges->httpClient = $this->getHttpMock($requestsContainer);
19+
$cryptoExchanges->httpClient = $this->getHttpMock(
20+
$requestsContainer, $this->loadJsonStubFile('api/v1/meta/crypto-exchanges.json')
21+
);
1822

1923
$cryptoExchanges->get();
2024

tests/Rest/Crypto/DailyOpenCloseTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@
33
namespace PolygonIO\Tests\Rest\Crypto;
44

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

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

1214
public function testDailyOpenCloseGetCall()
1315
{
1416
$requestsContainer = [];
1517

1618
$dailyOpenClose = new DailyOpenClose('fake-api-key');
17-
$dailyOpenClose->httpClient = $this->getHttpMock($requestsContainer);
19+
$dailyOpenClose->httpClient = $this->getHttpMock(
20+
$requestsContainer,
21+
$this->loadJsonStubFile('api/v1/open-close/crypto/BTC/USD/2020-10-14.json')
22+
);
1823

19-
$dailyOpenClose->get('BTC', 'ETH', '2018-2-2');
24+
$dailyOpenClose->get('BTC', 'USD', '2020-10-14');
2025

21-
$this->assertPath($requestsContainer, '/v1/open-close/crypto/BTC/ETH/2018-2-2');
26+
$this->assertPath($requestsContainer, '/v1/open-close/crypto/BTC/USD/2020-10-14');
2227
}
2328
}

tests/Rest/Crypto/GroupedDailyTest.php

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

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

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

1214
public function testGroupedDailyGetCall()
1315
{
1416
$requestsContainer = [];
1517

1618
$groupedDaily = new GroupedDaily('fake-api-key');
1719
$groupedDaily->httpClient = $this->getHttpMock(
18-
$requestsContainer, [
19-
'results' => [],
20-
]
20+
$requestsContainer, $this->loadJsonStubFile('api/v2/aggs/grouped/locale/global/market/crypto/2020-10-14.json')
2121
);
2222

23-
$groupedDaily->get('2019-2-2');
23+
$groupedDaily->get('2020-10-14');
2424

25-
$this->assertPath($requestsContainer, '/v2/aggs/grouped/locale/US/market/CRYPTO/2019-2-2');
25+
$this->assertPath($requestsContainer, '/v2/aggs/grouped/locale/global/market/crypto/2020-10-14');
2626
}
2727
}

tests/Rest/Crypto/HistoricCryptoTradeTest.php

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

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

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

1214
public function testHistoricCryptoTradeGetCall()
1315
{
1416
$requestsContainer = [];
1517

1618
$historicCryptoTrade = new HistoricCryptoTrade('fake-api-key');
1719
$historicCryptoTrade->httpClient = $this->getHttpMock(
18-
$requestsContainer, [
19-
'ticks' => [],
20-
]
20+
$requestsContainer, $this->loadJsonStubFile('api/v1/historic/crypto/BTC/USD/2020-10-14.json')
2121
);
2222

23-
$historicCryptoTrade->get('BTC', 'ETH', '2018-2-2');
23+
$historicCryptoTrade->get('BTC', 'USD', '2020-10-14');
2424

25-
$this->assertPath($requestsContainer, '/v1/historic/crypto/BTC/ETH/2018-2-2');
25+
$this->assertPath($requestsContainer, '/v1/historic/crypto/BTC/USD/2020-10-14');
2626
}
2727
}

tests/Rest/Crypto/LastTradeForCryptoPairTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@
33
namespace PolygonIO\Tests\Rest\Crypto;
44

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

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

1214
public function testLastTradeForCryptoPairGetCall()
1315
{
1416
$requestsContainer = [];
1517

1618
$lastTradeForCryptoPair = new LastTradeForCryptoPair('fake-api-key');
17-
$lastTradeForCryptoPair->httpClient = $this->getHttpMock($requestsContainer);
19+
$lastTradeForCryptoPair->httpClient = $this->getHttpMock(
20+
$requestsContainer,
21+
$this->loadJsonStubFile('api/v1/last/crypto/BTC/USD.json')
22+
);
1823

19-
$lastTradeForCryptoPair->get('BTC', 'ETH');
24+
$lastTradeForCryptoPair->get('BTC', 'USD');
2025

21-
$this->assertPath($requestsContainer, '/v1/last/crypto/BTC/ETH');
26+
$this->assertPath($requestsContainer, '/v1/last/crypto/BTC/USD');
2227
}
2328
}

0 commit comments

Comments
 (0)