From 27a882ed5771db8b9fe839b94350b5914450fb3b Mon Sep 17 00:00:00 2001 From: Angelo Maiorano Date: Wed, 17 Mar 2021 08:49:04 +0100 Subject: [PATCH 1/6] Laravel 8 Support --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index c8502ac..b09fa67 100644 --- a/composer.json +++ b/composer.json @@ -18,10 +18,10 @@ ], "require": { "php": ">=7.2", - "illuminate/notifications": "~5.5 || ~6.0 || ~7.0", - "illuminate/support": "~5.5 || ~6.0 || ~7.0", - "illuminate/events": "~5.5 || ~6.0 || ~7.0", - "illuminate/queue": "~5.5 || ~6.0 || ~7.0", + "illuminate/notifications": "~5.5 || ~6.0 || ~7.0 || ~8.0", + "illuminate/support": "~5.5 || ~6.0 || ~7.0 || ~8.0", + "illuminate/events": "~5.5 || ~6.0 || ~7.0 || ~8.0", + "illuminate/queue": "~5.5 || ~6.0 || ~7.0 || ~8.0", "plivo/plivo-php": "^1.1" }, "require-dev": { From c8d450d5640881b51db5ae8c1cff8d04f9590f53 Mon Sep 17 00:00:00 2001 From: Angelo Maiorano Date: Wed, 17 Mar 2021 10:26:24 +0100 Subject: [PATCH 2/6] Update pplivo to ^4.0 --- composer.json | 2 +- src/PlivoChannel.php | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index b09fa67..f513a06 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "illuminate/support": "~5.5 || ~6.0 || ~7.0 || ~8.0", "illuminate/events": "~5.5 || ~6.0 || ~7.0 || ~8.0", "illuminate/queue": "~5.5 || ~6.0 || ~7.0 || ~8.0", - "plivo/plivo-php": "^1.1" + "plivo/plivo-php": "^4.0" }, "require-dev": { "mockery/mockery": "^1.3", diff --git a/src/PlivoChannel.php b/src/PlivoChannel.php index 4e5e622..2c95b9b 100644 --- a/src/PlivoChannel.php +++ b/src/PlivoChannel.php @@ -46,7 +46,7 @@ public function __construct(Plivo $plivo) */ public function send($notifiable, Notification $notification) { - if (! $to = $notifiable->routeNotificationFor('plivo')) { + if (!$to = $notifiable->routeNotificationFor('plivo')) { return; } @@ -56,12 +56,12 @@ public function send($notifiable, Notification $notification) $message = new PlivoMessage($message); } - $response = $this->plivo->send_message([ - 'src' => $message->from ?: $this->from, - 'dst' => $to, - 'text' => trim($message->content), - 'url' => $message->webhook ?: $this->webhook, - ]); + $response = $this->plivo->messages->create( + $message->from ?: $this->from, + [$to], + trim($message->content), + ['url' => $message->webhook ?: $this->webhook] + ); if ($response['status'] !== 202) { throw CouldNotSendNotification::serviceRespondedWithAnError($response); From 934ab9949629695cd8227e0369da2860ed6cb44f Mon Sep 17 00:00:00 2001 From: Angelo Maiorano Date: Wed, 17 Mar 2021 10:31:08 +0100 Subject: [PATCH 3/6] use Rest Api Updates --- src/Plivo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plivo.php b/src/Plivo.php index 0f6a094..ea88509 100644 --- a/src/Plivo.php +++ b/src/Plivo.php @@ -2,7 +2,7 @@ namespace NotificationChannels\Plivo; -use Plivo\RestAPI as PlivoRestApi; +use Plivo\RestClient as PlivoRestApi; class Plivo extends PlivoRestApi { From 2a283e6cfed6c9c452411d651191acaf857469a0 Mon Sep 17 00:00:00 2001 From: Angelo Maiorano Date: Wed, 17 Mar 2021 12:37:47 +0100 Subject: [PATCH 4/6] ServiceProvider autoload --- composer.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/composer.json b/composer.json index f513a06..4558016 100644 --- a/composer.json +++ b/composer.json @@ -43,5 +43,12 @@ }, "config": { "sort-packages": true + }, + "extra": { + "laravel": { + "providers": [ + "NotificationChannels\\Plivo\\PlivoServiceProvider" + ] + } } } From f30338dd39d30678c4f613d681d36e16868b8981 Mon Sep 17 00:00:00 2001 From: Angelo Maiorano Date: Wed, 17 Mar 2021 14:46:31 +0100 Subject: [PATCH 5/6] Update Plivo to ^4.0 : response format --- src/Exceptions/CouldNotSendNotification.php | 2 +- src/PlivoChannel.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Exceptions/CouldNotSendNotification.php b/src/Exceptions/CouldNotSendNotification.php index f3b91c2..e71e6de 100644 --- a/src/Exceptions/CouldNotSendNotification.php +++ b/src/Exceptions/CouldNotSendNotification.php @@ -6,6 +6,6 @@ class CouldNotSendNotification extends \Exception { public static function serviceRespondedWithAnError($response) { - return new static("Notification was not sent. Plivo responded with `{$response['status']}: {$response['response']['error']}`"); + return new static("Notification was not sent. Plivo responded with `{$response->statusCode}`: {$response->message}`"); } } diff --git a/src/PlivoChannel.php b/src/PlivoChannel.php index 2c95b9b..34bb233 100644 --- a/src/PlivoChannel.php +++ b/src/PlivoChannel.php @@ -63,7 +63,7 @@ public function send($notifiable, Notification $notification) ['url' => $message->webhook ?: $this->webhook] ); - if ($response['status'] !== 202) { + if ($response->statusCode !== 202) { throw CouldNotSendNotification::serviceRespondedWithAnError($response); } From c81d6f2304da52087340bc11999d93cb2aef0e38 Mon Sep 17 00:00:00 2001 From: Angelo Maiorano Date: Thu, 25 Mar 2021 08:58:28 +0100 Subject: [PATCH 6/6] Add message content to response --- src/PlivoChannel.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PlivoChannel.php b/src/PlivoChannel.php index 34bb233..f4aecd7 100644 --- a/src/PlivoChannel.php +++ b/src/PlivoChannel.php @@ -62,6 +62,8 @@ public function send($notifiable, Notification $notification) trim($message->content), ['url' => $message->webhook ?: $this->webhook] ); + + $response->message = $message; if ($response->statusCode !== 202) { throw CouldNotSendNotification::serviceRespondedWithAnError($response);