-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathRingCentral.php
More file actions
57 lines (45 loc) · 1.24 KB
/
RingCentral.php
File metadata and controls
57 lines (45 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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),
);
}
}