Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions src/Utopia/Messaging/Adapters/SMS/RingCentral.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Utopia\Messaging\Adapters\SMS;

use Utopia\Messaging\Adapters\SMS as SMSAdapter;
use Utopia\Messaging\Messages\SMS;

// Reference Material
// https://developers.ringcentral.com/sms-api

class RingCentral extends SMSAdapter
{
/**
* @param string $apiKey RingCentral API Key
*/
private string $apiKey;

public function __construct(string $apiKey)
{
$this->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),
);
}

}