From f63c1c95fe0148ccebeca5755c77d32d669a7c3c Mon Sep 17 00:00:00 2001 From: Aditya Oberai Date: Tue, 12 Jul 2022 15:45:22 +0000 Subject: [PATCH] Create Vonage phone auth adapter --- app/init.php | 2 ++ app/workers/messaging.php | 2 ++ src/Appwrite/Auth/Phone/Vonage.php | 42 ++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 src/Appwrite/Auth/Phone/Vonage.php diff --git a/app/init.php b/app/init.php index 0861f67e7..71407699b 100644 --- a/app/init.php +++ b/app/init.php @@ -28,6 +28,7 @@ use Appwrite\Auth\Phone\Telesign; use Appwrite\Auth\Phone\TextMagic; use Appwrite\Auth\Phone\Twilio; use Appwrite\Auth\Phone\Msg91; +use Appwrite\Auth\Phone\Vonage; use Appwrite\DSN\DSN; use Appwrite\Event\Audit; use Appwrite\Event\Database as EventDatabase; @@ -992,6 +993,7 @@ App::setResource('phone', function () { 'text-magic' => new TextMagic($user, $secret), 'telesign' => new Telesign($user, $secret), 'msg91' => new Msg91($user, $secret), + 'vonage' => new Vonage($user, $secret), default => null }; }); diff --git a/app/workers/messaging.php b/app/workers/messaging.php index c83eaa2d7..fd6eed6c2 100644 --- a/app/workers/messaging.php +++ b/app/workers/messaging.php @@ -6,6 +6,7 @@ use Appwrite\Auth\Phone\Telesign; use Appwrite\Auth\Phone\TextMagic; use Appwrite\Auth\Phone\Twilio; use Appwrite\Auth\Phone\Msg91; +use Appwrite\Auth\Phone\Vonage; use Appwrite\DSN\DSN; use Appwrite\Resque\Worker; use Utopia\App; @@ -38,6 +39,7 @@ class MessagingV1 extends Worker 'text-magic' => new TextMagic($user, $secret), 'telesign' => new Telesign($user, $secret), 'msg91' => new Msg91($user, $secret), + 'vonage' => new Vonage($user, $secret), default => null }; diff --git a/src/Appwrite/Auth/Phone/Vonage.php b/src/Appwrite/Auth/Phone/Vonage.php new file mode 100644 index 000000000..bf95360b2 --- /dev/null +++ b/src/Appwrite/Auth/Phone/Vonage.php @@ -0,0 +1,42 @@ +request( + method: 'POST', + url: $this->endpoint, + headers: $headers, + payload: \http_build_query([ + 'text' => $message, + 'from' => $from, + 'to' => $to, + 'api_key' => $this->user, + 'api_secret' => $this->secret + ]) + ); + } +}