Skip to content

Commit 41a6cd0

Browse files
committed
Merge branch 'stijnbernards-patch-1'
2 parents 4c7dd17 + d4eae96 commit 41a6cd0

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

src/Pushover.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ public function send(array $params, mixed $notifiable): ResponseInterface
8484
}
8585
}
8686

87-
//dd($multipart);
8887
return $this->http->post(
8988
$this->pushoverApiUrl,
9089
[

src/PushoverMessage.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ class PushoverMessage
8585
* @var string|null
8686
*/
8787
public string|null $image = null;
88+
/**
89+
* The (optional) publicly-accessible url that Pushover will use to notify your system when a user
90+
* acknowledges an Emergency notification.
91+
*
92+
* @var string|null
93+
*/
94+
public string|null $callback = null;
8895

8996
/**
9097
* Message formats.
@@ -324,6 +331,20 @@ public function emergencyPriority(int $retryTimeout, int $expireAfter): static
324331
return $this->priority(self::EMERGENCY_PRIORITY, $retryTimeout, $expireAfter);
325332
}
326333

334+
/**
335+
* Set the callback url used by pushover to let your system
336+
* know when a emergency notification has been acknowledged.
337+
*
338+
* @param string $url
339+
* @return $this
340+
*/
341+
public function callback(string $url): static
342+
{
343+
$this->callback = $url;
344+
345+
return $this;
346+
}
347+
327348
/**
328349
* Array representation of Pushover Message.
329350
*
@@ -344,6 +365,7 @@ public function toArray(): array
344365
'expire' => $this->expire,
345366
'html' => $this->format === static::FORMAT_HTML,
346367
'monospace' => $this->format === static::FORMAT_MONOSPACE,
368+
'callback' => $this->callback,
347369
];
348370
}
349371

tests/IntegrationTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public function it_can_send_a_pushover_notification_with_a_global_token(): void
5656
'expire' => 600,
5757
'html' => false,
5858
'monospace' => false,
59+
'callback' => null,
5960
'user' => 'pushover-key-30characters-long',
6061
'device' => 'iphone,desktop',
6162
]);
@@ -93,6 +94,7 @@ public function it_can_send_a_pushover_notification_with_an_overridden_token():
9394
'expire' => 600,
9495
'html' => true,
9596
'monospace' => false,
97+
'callback' => null,
9698
'user' => 'pushover-key-30characters-long',
9799
'device' => 'iphone,desktop',
98100
]);
@@ -109,7 +111,7 @@ public function it_can_send_a_pushover_notification_with_an_overridden_token():
109111
protected function requestWillBeSentToPushoverWith($params): void
110112
{
111113
$multipartData = array_map(
112-
fn ($key, $value) => ['name' => $key, 'contents' => $value],
114+
fn($key, $value) => ['name' => $key, 'contents' => $value],
113115
array_keys($params),
114116
array_values($params)
115117
);

tests/PushoverMessageTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,13 @@ public function it_can_set_the_priority_to_emergency(): void
190190

191191
$this->assertEquals(2, $this->message->priority);
192192
}
193+
194+
public function it_can_set_the_callback_url(): void
195+
{
196+
$callbackUrl = 'https://www.example.com/callback';
197+
198+
$this->message->callback($callbackUrl);
199+
200+
$this->assertEquals($callbackUrl, $this->message->callback);
201+
}
193202
}

0 commit comments

Comments
 (0)