textmagic

package
v0.0.0-...-db4472a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 3 Imported by: 0

README

TextMagic

go.dev reference

Prerequisites

You will need to have a TextMagic account and UserName and API KEY from TextMagic.(api-keys)

package main

import (
  "context"
  "log"

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

func main() {

  textMagicService := textmagic.New("YOUR_USER_NAME", "YOUR_API_KEY")

  textMagicService.AddReceivers("Destination1-Phone-Number")

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

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

  log.Printf("notification sent")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service allow you to configure a TextMagic SDK client.

func New

func New(userName, apiKey string) *Service

New creates a new text magic client. Use your user-name and API key from https://my.textmagic.com/online/api/rest-api/keys.

func (*Service) AddReceivers

func (s *Service) AddReceivers(phoneNumbers ...string)

AddReceivers adds the given phone numbers to the notifier.

func (*Service) Send

func (s *Service) Send(ctx context.Context, subject, message string) error

Send sends a SMS via TextMagic to all previously added receivers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL