Skip to content
Open
Changes from 1 commit
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
52 changes: 52 additions & 0 deletions src/Utopia/Messaging/Adapters/SMS/46elks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace Utopia\Messaging\Adapters\SMS;

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

// Reference Material
// https://46elks.com/docs/send-sms
class fortysixelks extends SMSAdapter
Comment thread
DhairyaMajmudar marked this conversation as resolved.
Outdated
{

/**
* @param string $apiKey 46elks API token
*/
public function __construct(
private string $apiKey
) {
}

public function getName(): string
{
return '46elks';
}

public function getMaxMessagesPerRequest(): int
{
return 1000;
}

/**
* {@inheritdoc}
*
* @throws \Exception
*/
protected function process(SMS $message): string
{
return $this -> request (
method:'POST',
url:'https://api.46elks.com/a1/sms',
headers: [
'Authorization: Basic '.$this->apiKey,
'Content-type: application/json',
],
body: \json_encode([
'message' => $message->getContent(),
'from' => $message->getFrom(),
'to' => $message->getTo(),
]),
);
}
}