diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 552b207d..144a8ed4 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 }} + SMSAPI_AUTH_TOKEN: ${{ secrets.SMSAPI_AUTH_TOKEN }} + SMSAPI_TO: ${{ secrets.SMSAPI_TO }} + SMSAPI_FROM: ${{ secrets.SMSAPI_FROM }} run: | docker compose up -d --build sleep 5 diff --git a/README.md b/README.md index d745b630..be172361 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/) +- [x] [SMSApi](https://www.smsapi.com/) ### Push - [x] [FCM](https://firebase.google.com/docs/cloud-messaging) diff --git a/docker-compose.yml b/docker-compose.yml index 80d626d9..35aebcbc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,6 +29,9 @@ services: - VONAGE_API_SECRET - VONAGE_TO - VONAGE_FROM + - SMSAPI_AUTH_TOKEN + - SMSAPI_TO + - SMSAPI_FROM build: context: . volumes: diff --git a/src/Utopia/Messaging/Adapters/SMS/SMSApi.php b/src/Utopia/Messaging/Adapters/SMS/SMSApi.php new file mode 100644 index 00000000..f4a799c1 --- /dev/null +++ b/src/Utopia/Messaging/Adapters/SMS/SMSApi.php @@ -0,0 +1,51 @@ +request( + method: 'POST', + url: 'https://api.smsapi.com/sms.do', + headers: [ + 'Authorization: Bearer '.$this->apiToken, + 'content-type: application/json', + ], + body: \json_encode([ + 'from' => $message->getFrom(), //sendername made in https://ssl.smsapi.com/sms_settings/sendernames + 'to' => $message->getTo()[0], //destination number + 'message' => $message->getContent(), //message content + ]), + ); + } +} diff --git a/tests/e2e/SMS/SMSApiTest.php b/tests/e2e/SMS/SMSApiTest.php new file mode 100644 index 00000000..e069eb2b --- /dev/null +++ b/tests/e2e/SMS/SMSApiTest.php @@ -0,0 +1,30 @@ +send($message); + // $result = \json_decode($response, true); + + // $this->assertEquals('success', $result['type']); + + $this->markTestSkipped('SMSApi currenlty not available in INDIA.'); + } +}