notify
notify copied to clipboard
feat(service): add twilio
Description
Adds Twilio (Messaging) service.
Resolves #115
Motivation and Context
Adds a new service to the list of the currently supported ones.
How Has This Been Tested?
Unit tests implemented under service/twilio/twilio_test.go
.
Integration tests have been performed using a trial account from Twilio Console.
Sample code to run an integration test.
package main
import (
"context"
"log"
"github.com/nikoksr/notify"
"github.com/nikoksr/notify/service/twilio"
)
func main() {
twilioSvc, err := twilio.New("account_sid", "auth_token", "your_phone_number")
if err != nil {
log.Fatalf("twilio.New() failed: %s", err.Error())
}
twilioSvc.AddReceivers("recipient_phone_number")
notifier := notify.New()
notifier.UseServices(twilioSvc)
err = notifier.Send(context.Background(), "subject", "message")
if err != nil {
log.Fatalf("notifier.Send() failed: %s", err.Error())
}
log.Println("notification sent")
}
Please find below sample images from the results of the integration tests.
Screenshots / Output (if appropriate):
Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Documentation (no code change)
- [ ] Refactor (refactoring production code)
- [ ] Other
Checklist:
- [x] My code follows the code style of this project.
- [x] I have updated the documentation accordingly.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
Codecov Report
Merging #276 (2879767) into main (836eb8a) will increase coverage by
0.81%
. The diff coverage is64.58%
.
@@ Coverage Diff @@
## main #276 +/- ##
==========================================
+ Coverage 54.62% 55.44% +0.81%
==========================================
Files 14 16 +2
Lines 540 588 +48
==========================================
+ Hits 295 326 +31
- Misses 222 235 +13
- Partials 23 27 +4
Impacted Files | Coverage Δ | |
---|---|---|
service/twilio/twilio.go | 56.00% <56.00%> (ø) |
|
service/twilio/mock_twilioClient.go | 73.91% <73.91%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 836eb8a...2879767. Read the comment docs.
Why is this not accepted @nikoksr ?
@svaloumas so sorry for the severe delay! I fixed all compatibility issues with main and it looks like we're read to merge.
Since I updated this branche's go.mod, I'd be very thankful if you could quickly verify that the Twillio service you wrote is actually still working with the latest changes.
I greatly appreciate your patience and effort!
Hey @nikoksr, no worries at all! I've just tested it once again after pulling your changes and it's still functional. 😄