From de511be680723252f8b1164847147fcd99f0b52c Mon Sep 17 00:00:00 2001 From: davidgrayston-paddle Date: Wed, 4 Dec 2024 09:24:59 +0000 Subject: [PATCH] fix: Notification replay now calls correct endpoint (#104) --- CHANGELOG.md | 6 ++++ examples/notification_replay.php | 32 +++++++++++++++++++ .../Notifications/NotificationsClient.php | 2 +- .../Notifications/NotificationsClientTest.php | 2 +- 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 examples/notification_replay.php diff --git a/CHANGELOG.md b/CHANGELOG.md index ca25e65..f970b5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx&utm_medium=paddle-php-sdk) for information about changes to the Paddle Billing platform, the Paddle API, and other developer tools. +## [Unreleased] + +### Fixed + +- `Client->notifications->replay()` now calls the correct endpoint + ## [1.5.0] - 2024-11-18 ### Added diff --git a/examples/notification_replay.php b/examples/notification_replay.php new file mode 100644 index 0000000..24015e6 --- /dev/null +++ b/examples/notification_replay.php @@ -0,0 +1,32 @@ +notifications->replay($notificationId); +} catch (ApiError|MalformedResponse $e) { + var_dump($e); + exit; +} + +echo sprintf("Replayed Notification ID: %s\n", $replayedNotificationId); diff --git a/src/Resources/Notifications/NotificationsClient.php b/src/Resources/Notifications/NotificationsClient.php index f96e79d..6db2df2 100644 --- a/src/Resources/Notifications/NotificationsClient.php +++ b/src/Resources/Notifications/NotificationsClient.php @@ -63,7 +63,7 @@ public function get(string $id): Notification public function replay(string $id): string { $parser = new ResponseParser( - $this->client->postRaw("/notifications/{$id}"), + $this->client->postRaw("/notifications/{$id}/replay"), ); $data = $parser->getData(); diff --git a/tests/Functional/Resources/Notifications/NotificationsClientTest.php b/tests/Functional/Resources/Notifications/NotificationsClientTest.php index af592e1..2620f48 100644 --- a/tests/Functional/Resources/Notifications/NotificationsClientTest.php +++ b/tests/Functional/Resources/Notifications/NotificationsClientTest.php @@ -170,7 +170,7 @@ public function replay_hits_expected_uri(): void self::assertInstanceOf(RequestInterface::class, $request); self::assertEquals('POST', $request->getMethod()); self::assertEquals( - sprintf('%s/notifications/nft_01h8441jn5pcwrfhwh78jqt8hk', Environment::SANDBOX->baseUrl()), + sprintf('%s/notifications/nft_01h8441jn5pcwrfhwh78jqt8hk/replay', Environment::SANDBOX->baseUrl()), urldecode((string) $request->getUri()), ); self::assertSame('ntf_01h46h1s2zabpkdks7yt4vkgkc', $replayId);