From e983a2f571ac01e36f62f99231a2a9982d3f70cf Mon Sep 17 00:00:00 2001 From: ShatilKhan Date: Tue, 17 Oct 2023 03:53:47 +0600 Subject: [PATCH] Added RingCentral SMS adapter --- .../Messaging/Adapters/SMS/RingCentral.php | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/Utopia/Messaging/Adapters/SMS/RingCentral.php diff --git a/src/Utopia/Messaging/Adapters/SMS/RingCentral.php b/src/Utopia/Messaging/Adapters/SMS/RingCentral.php new file mode 100644 index 00000000..2750d7ef --- /dev/null +++ b/src/Utopia/Messaging/Adapters/SMS/RingCentral.php @@ -0,0 +1,57 @@ +apiKey = $apiKey; + } + + public function getName(): string + { + return 'RingCentral'; + } + + public function getMaxMessagesPerRequest(): int + { + return 40; + } + + protected function process(SMS $message): string + { + $url = 'https://platform.devtest.ringcentral.com/restapi/v1.0/account/accountId/extension/extensionId/sms'; + + $headers = [ + 'Authorization: Bearer ' . $this->apiKey, + 'Content-Type: application/json', + ]; + + $data = [ + 'channel' => 'sms', + 'src' => $message->getFrom(), + 'dst' => $message->getTo()[0], + 'text' => $message->getContent(), + ]; + + return $this->request( + method: 'POST', + url: $url, + headers: $headers, + body: json_encode($data), + ); + } + +} \ No newline at end of file