Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Termii messaging adapter #52

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

biswajit287
Copy link

@biswajit287 biswajit287 commented Oct 11, 2023

What does this PR do?

This Pull Request (PR) adds Termii messaging adapter along with tests.

Test Plan

  1. Create Your Termii Account

    • Sign up for an account on Termii.
  2. Obtain API Key

    • Log in to your Termii dashboard and go to "Api console" under Developers.
    • Retrieve your API key from this section.
  3. Create Sender Id (For Sending message)

    • To register the sender id, you need to apply in "SMS Sender ids" section under Rental.
  4. Set Environment Variables and Run E2E Tests

    • Before running end-to-end (E2E) tests, make sure you have the following environment variables set:

      • TERMII_API_KEY
      • TERMII_TO
      • TERMII_FROM
    • Execute the following command to run the E2E tests:

      ./vendor/bin/phpunit --verbose tests/e2e/SMS/TermiiTest.php

Related PRs and Issues

Closes appwrite/appwrite#6864

Have you read the Contributing Guidelines on issues?

Yes

@biswajit287 biswajit287 marked this pull request as draft October 11, 2023 19:23
@biswajit287 biswajit287 marked this pull request as ready for review October 26, 2023 12:05
@stnguyen90 stnguyen90 self-requested a review October 26, 2023 15:53
Copy link
Contributor

@stnguyen90 stnguyen90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR! 🤯 We left some comments during the review, please check them out.

src/Utopia/Messaging/Adapters/SMS/Termii.php Show resolved Hide resolved
*/
private function getRequestBody(array $to, string $text, string $from = null): array
{
$from = $from ?? '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's okay to pass an empty string for from?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it will throw exception as Invalid Sender Id

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And what if null is passed?

Copy link
Author

@biswajit287 biswajit287 Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, sorry for late reply. I was busy on some office work.
If null/empty from passed then also it will throw exception

Exception: {"message":"The given data was invalid.","errors":{"from":["The from field is required."]}}

Comment on lines +71 to +73
if (count($to) == 1) {
$to = $to[0];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do they not accept an array with 1 element?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about that, based on the documentation they just mentioned that to send to multiple numbers we need to pass as array

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to test and see so that you can clean up this code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I am unable to test the service anymore as my account balance is low. Termii does not provide free testing and since I am testing from India cost is high.

Exception: {"message":"Insufficient balance"}

Copy link
Contributor

@stnguyen90 stnguyen90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure to attach screenshots of successful tests to the PR

src/Utopia/Messaging/Adapters/SMS/Termii.php Show resolved Hide resolved
Comment on lines +71 to +73
if (count($to) == 1) {
$to = $to[0];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to test and see so that you can clean up this code.

@tessamero
Copy link

Hello @biswajit287

Thank you for your contribution to Hacktoberfest 2023! We've noticed that your PR is still pending and requires some updates based on our engineering team's feedback.

We would love to see your PR successfully merged and send you the Appwrite swag as a token of appreciation. To remain eligible for the swag, please address the pending suggestions by Friday, November 17th. If the PR isn't updated by then, we will unfortunately have to close it due to the end of the Hacktoberfest event.

@biswajit287
Copy link
Author

Hi @stnguyen90 , I'll not be able to attach sreenshots of succesfull test as I'm unable to test the service anymore. My account balance is low. Termii does not provide free testing and since I am using from India cost is high.

Exception: {"message":"Insufficient balance"}

@gewenyu99
Copy link

Hey there! There were a lot of big PRs during this Hacktoberfest, and we wanted to give everyone ample time to collaborate with our engineering team. If you were able to merge your PRs during October, amazing. If it’s still not merged, don’t worry about it either. Either way, we’ve got your Hacktoberfest swag minted and ready to ship.

Please comment with your Discord username here so we can contact you about your shipping information to deliver your Hacktoberfest swag.

@biswajit287
Copy link
Author

Hi @gewenyu99,
My discord username is biswajit27

@gewenyu99
Copy link

Will reach out soon. Compiling everyone's user names. Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

💬 Improve Appwrite Messaging with Termii
4 participants