1
0
mirror of https://github.com/nikoksr/notify.git synced 2024-11-28 08:39:13 +02:00
notify/service/plivo
Prashanth Pai 67b2d011b8 feat(service): Add Plivo service
Added support for Plivo as a backend service with unit tests and
documentation.

Signed-off-by: Prashanth Pai <mail@ppai.me>
2021-02-09 09:30:52 +05:30
..
doc.go feat(service): Add Plivo service 2021-02-09 09:30:52 +05:30
mock_plivoMsgClient.go feat(service): Add Plivo service 2021-02-09 09:30:52 +05:30
plivo_test.go feat(service): Add Plivo service 2021-02-09 09:30:52 +05:30
plivo.go feat(service): Add Plivo service 2021-02-09 09:30:52 +05:30
README.md feat(service): Add Plivo service 2021-02-09 09:30:52 +05:30

Plivo

go.dev reference

Prerequisites

You will need to have a Plivo account and the following things:

  1. Auth ID and Auth Token from Plivo console.
  2. An active rented Plivo phone number.

Usage

package main

import (
	"log"

	"github.com/nikoksr/notify"
	"github.com/nikoksr/notify/service/plivo"
)

func main() {
	plivoSvc, err := plivo.New(
		&plivo.ClientOptions{
			AuthID:    "<Your-Plivo-Auth-Id>",
			AuthToken: "<Your-Plivo-Auth-Token>",
		}, &plivo.MessageOptions{
			Source: "<Your-Plivo-Source-Number>",
		})
	if err != nil {
		log.Fatalf("plivo.New() failed: %s", err.Error())
	}

	plivoSvc.AddReceivers("Destination1")

	notifier := notify.New()
	notifier.UseServices(plivoSvc)

	err = notifier.Send("subject", "message")
	if err != nil {
		log.Fatalf("notifier.Send() failed: %s", err.Error())
	}

	log.Printf("notification sent")
}