Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for invalid dates on higher layer #6

Open
5 tasks
maciej-sz opened this issue May 3, 2023 · 0 comments
Open
5 tasks

Add support for invalid dates on higher layer #6

maciej-sz opened this issue May 3, 2023 · 0 comments

Comments

@maciej-sz
Copy link
Owner

maciej-sz commented May 3, 2023

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant