diff --git a/src/Utopia/Messaging/Adapters/SMS/Mobivate.php b/src/Utopia/Messaging/Adapters/SMS/Mobivate.php new file mode 100644 index 00000000..04103ce1 --- /dev/null +++ b/src/Utopia/Messaging/Adapters/SMS/Mobivate.php @@ -0,0 +1,62 @@ +getTo() as $to) { + $temp = [ + 'originator' => $message->getFrom(), + 'recipient' => \ltrim($to, '+'), + 'text' => $message->getContent(), + ]; + array_push($messages, $temp); + } + + return $this->request( + method: 'POST', + url: 'https://api.mobivatebulksms.com/send/batch', + headers: [ + 'content-type: application/json', + 'Authorization: Bearer '.$this->apiKey, + ], + body: \json_encode([ + 'routeId' => $this->routeId, + 'messages' => $messages, + ]), + ); + } +} diff --git a/tests/e2e/SMS/MobivateTest.php b/tests/e2e/SMS/MobivateTest.php new file mode 100644 index 00000000..c54426ef --- /dev/null +++ b/tests/e2e/SMS/MobivateTest.php @@ -0,0 +1,31 @@ +send($message)); + + $this->assertNotEmpty($result); + $this->assertCount(\count($to), $result->recipients); + $this->assertEquals($result->routeId, getenv('MOBIVATE_ROUTE_ID')); + } +}