notify icon indicating copy to clipboard operation
notify copied to clipboard

feat(service): add twilio

Open svaloumas opened this issue 2 years ago • 4 comments

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):

IMAGE 2022-05-11 17:10:09

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.

svaloumas avatar May 11 '22 14:05 svaloumas

Codecov Report

Merging #276 (2879767) into main (836eb8a) will increase coverage by 0.81%. The diff coverage is 64.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.

codecov-commenter avatar May 13 '22 18:05 codecov-commenter

Why is this not accepted @nikoksr ?

emmanuelay avatar Jun 22 '22 19:06 emmanuelay

@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!

nikoksr avatar Aug 04 '22 14:08 nikoksr

Hey @nikoksr, no worries at all! I've just tested it once again after pulling your changes and it's still functional. 😄

photo_2022-08-04 23 12 13

svaloumas avatar Aug 04 '22 20:08 svaloumas