-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Labels
Description
Currently invalid dates are thrown on the transport level.
Example 1
public function testFromMonthInTheFuture()
{
$inTwoMonths = (new \DateTimeImmutable())->add(new \DateInterval('P2M'));
$currencyAverages = CurrencyAverageRatesService::create();
$rates = $currencyAverages->fromMonth(...extract_ym($inTwoMonths));
var_dump($rates->fromTable('A')->toArray());
}Causes: ClientException : HTTP/1.1 400 B��dny zakres dat / Invalid date range returned for...
Example 2
public function testFromMonthBeforeRecords()
{
$currencyAverages = CurrencyAverageRatesService::create();
$rates = $currencyAverages->fromMonth(1970, 1);
var_dump($rates->fromTable('A')->toArray());
}Causes:
ClientException : HTTP/1.1 404 Bark danych / No data available returned for...
Example 3
public function testFromDayBeforeInvalid()
{
$inTwoMonths = (new \DateTimeImmutable())->add(new \DateInterval('P2M'));
self::expectException(RateNotFoundException::class);
self::expectExceptionMessage("Gold rate from day before {$inTwoMonths->format('Y-m-d')} has not been found");
$goldRates = GoldRatesService::create();
$goldRates->fromDayBefore($inTwoMonths);
}Causes:
ClientException : HTTP/1.1 400 B��dny zakres dat / Invalid date range returned for ...
Todo
- Move exceptions to higher layer
- Handle caching of invalid requests (?)
- Tests for average rates
- Tests for trading rates
- Tests for gold rates