From 50420752c3db50842b2a4af57f607d1ab427382c Mon Sep 17 00:00:00 2001 From: fadkeabhi <31249309+fadkeabhi@users.noreply.github.com> Date: Mon, 2 Oct 2023 15:23:59 +0530 Subject: [PATCH] Added Mobivate API Added Support for Mobivate. Also Added and performed tests for same. --- .../Messaging/Adapters/SMS/Mobivate.php | 64 +++++++++++++++++++ tests/e2e/SMS/MobivateTest.php | 34 ++++++++++ 2 files changed, 98 insertions(+) create mode 100644 src/Utopia/Messaging/Adapters/SMS/Mobivate.php create mode 100644 tests/e2e/SMS/MobivateTest.php diff --git a/src/Utopia/Messaging/Adapters/SMS/Mobivate.php b/src/Utopia/Messaging/Adapters/SMS/Mobivate.php new file mode 100644 index 00000000..f1f149f8 --- /dev/null +++ b/src/Utopia/Messaging/Adapters/SMS/Mobivate.php @@ -0,0 +1,64 @@ +getTo() as $to){ + $temp = array( + "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 + ]), + ); + } +} \ No newline at end of file diff --git a/tests/e2e/SMS/MobivateTest.php b/tests/e2e/SMS/MobivateTest.php new file mode 100644 index 00000000..1bee04d3 --- /dev/null +++ b/tests/e2e/SMS/MobivateTest.php @@ -0,0 +1,34 @@ +send($message)); + + $this->assertNotEmpty($result); + $this->assertCount(\count($to),$result->recipients); + $this->assertEquals($result->routeId, getenv('MOBIVATE_ROUTE_ID')) + + } +}