Skip to content

Commit 4382eb4

Browse files
authored
Merge pull request #132 from spatie/ohdear-monitor
Fix verify command
2 parents 5545a80 + 272dc4c commit 4382eb4

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/Commands/VerifyCommand.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function handle()
2424
$this
2525
->verifySdkInstalled()
2626
->verifyApiToken($ohDearConfig)
27-
->verifySiteId($ohDearConfig)
27+
->verifyMonitorId($ohDearConfig)
2828
->verifyConnection($ohDearConfig);
2929

3030
render(view('schedule-monitor::alert', [
@@ -61,14 +61,14 @@ protected function verifyApiToken(array $ohDearConfig): self
6161
return $this;
6262
}
6363

64-
protected function verifySiteId(array $ohDearConfig): self
64+
protected function verifyMonitorId(array $ohDearConfig): self
6565
{
6666
if (empty($ohDearConfig['monitor_id'])) {
67-
throw new Exception('No site id found. Make sure you added an site id to the `monitor_id` key of the `schedule-monitor` config file. You can found your site id on the settings page of a site on Oh Dear.');
67+
throw new Exception('No monitor id found. Make sure you added an monitor id to the `monitor_id` key of the `schedule-monitor` config file. You can found your monitor id on the settings page of a monitor on Oh Dear.');
6868
}
6969

7070
render(view('schedule-monitor::alert', [
71-
'message' => 'Oh Dear site id found.',
71+
'message' => 'Oh Dear monitor id found.',
7272
]));
7373

7474
return $this;
@@ -78,10 +78,10 @@ protected function verifyConnection(array $ohDearConfig)
7878
{
7979
$this->comment('Trying to reach Oh Dear...');
8080

81-
$site = app(OhDear::class)->Monitor($ohDearConfig['monitor_id']);
81+
$monitor = app(OhDear::class)->monitor($ohDearConfig['monitor_id']);
8282

8383
render(view('schedule-monitor::alert', [
84-
'message' => "Successfully connected to Oh Dear. The configured site URL is: {$site->sortUrl}",
84+
'message' => "Successfully connected to Oh Dear. The configured monitor URL is: {$monitor->sortUrl}",
8585
]));
8686

8787
return $this;

src/Support/OhDear/OhDear.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ public function __construct(string $apiToken, string $baseUri = 'https://ohdear.
1919
$this->baseUri = rtrim($baseUri, '/');
2020
}
2121

22-
public function monitor(int $monitorId): Monitor
22+
public function monitor(int $monitorId): ?array
2323
{
24-
$monitorAttributes = $this->get("monitors/{$monitorId}");
25-
26-
return new Monitor($monitorAttributes, $this);
24+
return $this->get("monitors/{$monitorId}");
2725
}
2826

2927
public function createCronCheck(
@@ -75,10 +73,10 @@ protected function post(string $endpoint, array $data): array
7573
$response = Http::withToken($this->apiToken)
7674
->acceptJson()
7775
->post("{$this->baseUri}/{$endpoint}", $data);
78-
76+
7977
$response->throw();
8078

81-
79+
8280
return $response->json();
8381
} catch (RequestException $e) {
8482
;

0 commit comments

Comments
 (0)