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

feat!: make Twilio not singleton #675

Closed
wants to merge 40 commits into from

Conversation

SimonOsnes
Copy link

Fixes #650

Major version update.
Twilio class is no longer static singleton. Make it possible to have multiple instances of Twilio within the same program. Implement new TwilioApi.
Also update tests and example code.

Add few testcases to RequestValidatorTest.java as per issue #645

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

emilmyresten and others added 30 commits March 4, 2022 11:35
* feat: twilio implements twilioapi, changed usage examples

* feat: change initialization of all tests (#3)

* refactor: moved static block in twilio.java (#5)

* refactor: changed this to static methods (#5)

* feat: twilio class and interface final (#1 #5)

* refactor: change synchronized back to original version (#3)
…ethod (#7)

* git: update gitignore

* feat: updated creator abstract methods to take Twilio object (#7)

* fix: update examples to use twilio object as argument in create-method (#7)
* test: replace .create() with .create(tw) to conform to new usage (#7)

Fixes #7
* fix: bug in setUsername method (#17)
…) in tests (#21)

* test: update new method call .update() to .update(tw) (#13)
feat: update Fetcher class methods to take Twilio object and changes tests accordingly (#11)
docs: adds essence to repo report (#2)
@SimonOsnes SimonOsnes closed this Nov 14, 2022
@Earth-Turtle
Copy link

Is there a reason this pull request was closed? Allowing the Twilio client to be an object instead of static singleton makes it easier to mock and manage initialization.

In particular, trying to create a reusable object by using the TwilioRestClient.Builder, you have to supply the username and password immediately on creating the builder, where it can no longer be changed once the rest client is built. This clashes with the ability to call Twilio.setUsername() on the static instance whenever needed.

@SimonOsnes
Copy link
Author

@Earth-Turtle

This PR was made as a school project and when after we submitted it, we did not receive any feedback or anything for like 8 months before I closed it. If you want to re-open it and continue the work that we started you are more than welcome to do it. We won't be doing anything more to this

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

Successfully merging this pull request may close these issues.

Java library should not use singletons
6 participants