diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 552b207d..553ffe74 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,6 +40,9 @@ jobs: VONAGE_API_SECRET: ${{ secrets.VONAGE_API_SECRET }} VONAGE_TO: ${{ secrets.VONAGE_TO }} VONAGE_FROM: ${{ secrets.VONAGE_FROM }} + CM_API_KEY: ${{ secrets.CM_API_KEY }} + CM_TO: ${{ secrets.CM_TO }} + CM_FROM: ${{ secrets.CM_FROM }} run: | docker compose up -d --build sleep 5 diff --git a/README.md b/README.md index d745b630..75330ef3 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ $messaging->send($message); - [x] [Sinch](https://www.sinch.com/) - [x] [Seven](https://www.seven.io/) - [ ] [SmsGlobal](https://www.smsglobal.com/) +- [ ] [CM](https://www.cm.com/) ### Push - [x] [FCM](https://firebase.google.com/docs/cloud-messaging) diff --git a/docker-compose.yml b/docker-compose.yml index 80d626d9..97bfa252 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,6 +29,9 @@ services: - VONAGE_API_SECRET - VONAGE_TO - VONAGE_FROM + - CM_API_KEY + - CM_TO + - CM_FROM build: context: . volumes: diff --git a/src/Utopia/Messaging/Adapters/SMS/CM.php b/src/Utopia/Messaging/Adapters/SMS/CM.php new file mode 100644 index 00000000..2c606a25 --- /dev/null +++ b/src/Utopia/Messaging/Adapters/SMS/CM.php @@ -0,0 +1,49 @@ +request( + method: 'POST', + url: 'https://api.cmtelecom.com/v1.0/message', + headers: [ + 'Content-Type: application/json', + 'Authorization: Bearer '.$this->apiKey, + ], + body: json_encode([ + 'from' => $message->getFrom(), + 'to' => $message->getTo()[0], + 'body' => $message->getContent(), + ]), + ); + } +} diff --git a/tests/e2e/SMS/CM.php b/tests/e2e/SMS/CM.php new file mode 100644 index 00000000..ed36025f --- /dev/null +++ b/tests/e2e/SMS/CM.php @@ -0,0 +1,35 @@ +send($message); + $result = \json_decode($response, true); + + $this->assertArrayNotHasKey('errors', $result); + $this->assertArrayHasKey('message_id', $result); + $this->assertArrayHasKey('message', $result); + $this->assertArrayHasKey('balance', $result); + } +}