Skip to content

Commit 2e56545

Browse files
authored
Merge pull request #59 from ohdearapp/bugfix/uptime-split
fix: add missing `split` param
2 parents 0ffd4c9 + e21c8a4 commit 2e56545

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/Concerns/SupportsUptimeEndpoints.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
namespace OhDear\PhpSdk\Concerns;
44

55
use OhDear\PhpSdk\Dto\Uptime;
6+
use OhDear\PhpSdk\Enums\UptimeSplit;
67
use OhDear\PhpSdk\Requests\Uptime\GetUptimeRequest;
78

89
trait SupportsUptimeEndpoints
910
{
1011
/** @return list<Uptime> */
11-
public function uptime(int $monitorId, string $startedAt, string $endedAt): array
12+
public function uptime(int $monitorId, string $startedAt, string $endedAt, UptimeSplit $split = UptimeSplit::Hour): array
1213
{
13-
$request = new GetUptimeRequest($monitorId, $startedAt, $endedAt);
14+
$request = new GetUptimeRequest($monitorId, $startedAt, $endedAt, $split);
1415

1516
return $this->send($request)->dtoOrFail();
1617
}

src/Enums/UptimeSplit.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace OhDear\PhpSdk\Enums;
6+
7+
enum UptimeSplit: string
8+
{
9+
case Hour = 'hour';
10+
case Day = 'day';
11+
case Month = 'month';
12+
}

src/Requests/Uptime/GetUptimeRequest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace OhDear\PhpSdk\Requests\Uptime;
44

55
use OhDear\PhpSdk\Dto\Uptime;
6+
use OhDear\PhpSdk\Enums\UptimeSplit;
67
use OhDear\PhpSdk\Helpers\Helpers;
78
use Saloon\Enums\Method;
89
use Saloon\Http\Request;
@@ -16,6 +17,7 @@ public function __construct(
1617
protected int $monitorId,
1718
protected string $startedAt,
1819
protected string $endedAt,
20+
protected UptimeSplit $split = UptimeSplit::Hour,
1921
) {}
2022

2123
public function resolveEndpoint(): string
@@ -30,6 +32,7 @@ protected function defaultQuery(): array
3032
'started_at' => Helpers::convertDateFormat($this->startedAt),
3133
'ended_at' => Helpers::convertDateFormat($this->endedAt),
3234
],
35+
'split' => $this->split->value,
3336
];
3437
}
3538

0 commit comments

Comments
 (0)