Skip to content

Commit

Permalink
add new webmodels
Browse files Browse the repository at this point in the history
  • Loading branch information
cevro committed Sep 23, 2022
1 parent 5f98975 commit 7969030
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/FKSDBDownloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function downloadJSON(Request $request): string
);
restore_error_handler();
if ($result === false) {
$result = error_get_last();
$result = error_get_last()['message'];
}
return $result;
}
Expand Down
38 changes: 38 additions & 0 deletions src/Requests/SeriesResultsRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace Fykosak\FKSDBDownloaderCore\Requests;

class SeriesResultsRequest implements Request
{
private int $contestId;
private int $year;
private int $series;

public function __construct(int $contestId, int $year, int $series)
{
$this->contestId = $contestId;
$this->year = $year;
$this->series = $series;
}

public function getMethod(): string
{
return 'GetSeriesResults';
}

public function getParams(): array
{
return [
'contestId' => $this->contestId,
'year' => $this->year,
'series' => $this->series,
];
}

public function getCacheKey(): string
{
return sprintf('series.results.%s.%s.%s', $this->contestId, $this->year, $this->series);
}
}
35 changes: 35 additions & 0 deletions src/Requests/StatsRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace Fykosak\FKSDBDownloaderCore\Requests;

class StatsRequest implements Request
{
private int $contestId;
private int $year;

public function __construct(int $contestId, int $year)
{
$this->contestId = $contestId;
$this->year = $year;
}

public function getMethod(): string
{
return 'GetStats';
}

public function getParams(): array
{
return [
'contestId' => $this->contestId,
'year' => $this->year,
];
}

public function getCacheKey(): string
{
return sprintf('task.stats.%s.%s', $this->contestId, $this->year);
}
}

0 comments on commit 7969030

Please sign in to comment.