pushover

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2015 License: MIT Imports: 9 Imported by: 2

README

pushover

Package documentation

Push notifications to your phone or browser via Pushover.

Install latest stable version with go get:

go get -u github.com/AlekSi/pushover

Install command-line client with go get:

go get -u github.com/AlekSi/pushover/pushover
pushover -h

Documentation

Overview

Package pushover provides client for Pushover API (http://pushover.net/).

Index

Constants

View Source
const (
	LowestPriority    = -2 // lowest priority, no notification
	LowPriority       = -1 // low priority, no sound and vibration
	NormalPriority    = 0  // normal priority, default
	HighPriority      = 1  // high priority, always with sound and vibration
	EmergencyPriority = 2  // emergency priority, requires acknowledge
)

Message priority.

View Source
const (
	PushoverSound     = "pushover"
	BikeSound         = "bike"
	BugleSound        = "bugle"
	CashregisterSound = "cashregister"
	ClassicalSound    = "classical"
	CosmicSound       = "cosmic"
	FallingSound      = "falling"
	GamelanSound      = "gamelan"
	IncomingSound     = "incoming"
	IntermissionSound = "intermission"
	MagicSound        = "magic"
	MechanicalSound   = "mechanical"
	PianobarSound     = "pianobar"
	SirenSound        = "siren"
	SpacealarmSound   = "spacealarm"
	TugboatSound      = "tugboat"
	AlienSound        = "alien"
	ClimbSound        = "climb"
	PersistentSound   = "persistent"
	EchoSound         = "echo"
	UpdownSound       = "updown"
	NoneSound         = "none"
)

Message sound.

Variables

This section is empty.

Functions

func Send

func Send(message *Message) error

Send sends message. It does not retries failed sends. Returns either nil, TemporaryError or FatalError.

func SendMessage

func SendMessage(user, message string) error

SendMessage sends message to specified user. It does not retries failed sends. Returns either nil, TemporaryError or FatalError.

func SendMessageWithRetries

func SendMessageWithRetries(user, message string, maxRetries int) error

SendMessageWithRetries sends message to specified user. It does retries failed sends for temporary errors up to maxRetries times with 5 second delay. Specify maxRetries <= 0 for unlimited retries. Returns either nil, TemporaryError (if gave up) or FatalError.

func SendWithRetries

func SendWithRetries(message *Message, maxRetries int) error

SendWithRetries sends message. It does retries failed sends for temporary errors up to maxRetries times with 5 second delay. Specify maxRetries <= 0 for unlimited retries. Returns either nil, TemporaryError (if gave up) or FatalError.

Types

type Client

type Client struct {
	ApplicationToken string       // application API token
	HTTPClient       *http.Client // if nil, http.DefaultClient is used
}

Client sends messages.

var DefaultClient Client

DefaultClient is a default client for this package.

func (*Client) Send

func (c *Client) Send(message *Message) error

Send sends message. It does not retries failed sends. Returns either nil, TemporaryError or FatalError.

func (*Client) SendMessage

func (c *Client) SendMessage(user, message string) error

SendMessage sends message to specified user. It does not retries failed sends. Returns either nil, TemporaryError or FatalError.

func (*Client) SendMessageWithRetries

func (c *Client) SendMessageWithRetries(user, message string, maxRetries int) error

SendMessageWithRetries sends message to specified user. It does retries failed sends for temporary errors up to maxRetries times with 5 second delay. Specify maxRetries <= 0 for unlimited retries. Returns either nil, TemporaryError (if gave up) or FatalError.

func (*Client) SendWithRetries

func (c *Client) SendWithRetries(message *Message, maxRetries int) error

SendWithRetries sends message. It does retries failed sends for temporary errors up to maxRetries times with 5 second delay. Specify maxRetries <= 0 for unlimited retries. Returns either nil, TemporaryError (if gave up) or FatalError.

type FatalError

type FatalError struct {
	StatusCode int
	Message    string
}

FatalError implementes net.Error and represents fatal error. Request should not be retried.

func (*FatalError) Error

func (c *FatalError) Error() string

func (*FatalError) Temporary

func (c *FatalError) Temporary() bool

func (*FatalError) Timeout

func (c *FatalError) Timeout() bool

type Message

type Message struct {
	// mandatory parameters
	User    string // user/group key
	Message string // message to send

	// optional parameters
	Device    string    // device name to send the message directly to that device, rather than all of the user's devices
	Title     string    // message title
	URL       string    // supplementary URL
	URLTitle  string    // title for supplementary URL
	Priority  int       // priority, defaults to NormalPriority
	Timestamp time.Time // message time
	Sound     string    // message sound

	// for emergency priority only
	Retry    int
	Expire   int
	Callback string
}

Message to send.

type TemporaryError

type TemporaryError struct {
	StatusCode int
	Message    string
}

TemporaryError implementes net.Error and represents temporary error. Request may be retried later after 5 second delay.

func (*TemporaryError) Error

func (c *TemporaryError) Error() string

func (*TemporaryError) Temporary

func (c *TemporaryError) Temporary() bool

func (*TemporaryError) Timeout

func (c *TemporaryError) Timeout() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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