Documentation
¶
Overview ¶
Package plivo provides message notification integration for Plivo.
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(context.Background(), "subject", "message")
if err != nil {
log.Fatalf("notifier.Send() failed: %s", err.Error())
}
log.Printf("notification sent")
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientOptions ¶
type ClientOptions struct {
AuthID string // If empty, env variable PLIVO_AUTH_ID will be used
AuthToken string // If empty, env variable PLIVO_AUTH_TOKEN will be used
// Optional
HTTPClient *http.Client // Bring Your Own Client
}
ClientOptions allow you to configure a Plivo SDK client.
type MessageOptions ¶
type MessageOptions struct {
Source string // a Plivo source phone number or a Plivo Powerpack UUID
// Optional
CallbackURL string // URL to which status update callbacks for the message should be sent
CallbackMethod string // The HTTP method to be used when calling CallbackURL - GET or POST(default)
}
MessageOptions allow you to configure options for sending a message.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a Plivo client.
func New ¶
func New(cOpts *ClientOptions, mOpts *MessageOptions) (*Service, error)
New creates a new instance of plivo service.
func (*Service) AddReceivers ¶
AddReceivers adds the given destination phone numbers to the notifier.
Click to show internal directories.
Click to hide internal directories.