smsglobal

package
v0.0.0-...-a67d69f Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ErrSMSContactNotFound is a general error code for "SMS Contact not found."
	ErrSMSContactNotFound = "SMS Contact not found."
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	Contacts []Contact `json:"contacts"`
	Username string    `json:"username"`
	Password string    `json:"password"`
	SendFrom string    `json:"send_from"`
}

Base struct stores information related to the SMSGlobal package

var (
	SMSGlobal *Base
)

vars for the SMS global package

func New

func New(username, password, sendFrom string, contacts []Contact) *Base

New initialises the SMSGlobal var

func (*Base) AddContact

func (s *Base) AddContact(contact Contact)

AddContact checks to see if a contact exists and adds them if it doesn't

func (*Base) ContactExists

func (s *Base) ContactExists(contact Contact) bool

ContactExists checks to see if a contact exists

func (*Base) GetContactByName

func (s *Base) GetContactByName(name string) (Contact, error)

GetContactByName returns a contact with supplied name

func (*Base) GetContactByNumber

func (s *Base) GetContactByNumber(number string) (Contact, error)

GetContactByNumber returns a contact with supplied number

func (*Base) GetEnabledContacts

func (s *Base) GetEnabledContacts() int

GetEnabledContacts returns how many SMS contacts are enabled in the contact list

func (*Base) RemoveContact

func (s *Base) RemoveContact(contact Contact)

RemoveContact removes a contact if it exists

func (*Base) SendMessage

func (s *Base) SendMessage(to, message string) error

SendMessage sends a message to an individual contact

func (*Base) SendMessageToAll

func (s *Base) SendMessageToAll(message string)

SendMessageToAll sends a message to all enabled contacts in cfg

type Contact

type Contact struct {
	Name    string `json:"name"`
	Number  string `json:"number"`
	Enabled bool   `json:"enabled"`
}

Contact struct stores information related to a SMSGlobal contact

Jump to

Keyboard shortcuts

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