Documentation ¶
Overview ¶
Package pushover provides a wrapper around the Pushover API
Index ¶
- Constants
- Variables
- type Errors
- type Limit
- type Message
- type Pushover
- func (p *Pushover) CancelEmergencyNotification(receipt string) (*Response, error)
- func (p *Pushover) GetReceiptDetails(receipt string) (*ReceiptDetails, error)
- func (p *Pushover) GetRecipientDetails(recipient *Recipient) (*RecipientDetails, error)
- func (p *Pushover) SendMessage(message *Message, recipient *Recipient) (*Response, error)
- type ReceiptDetails
- type Recipient
- type RecipientDetails
- type Response
Constants ¶
const ( // MessageMaxLength is the max message number of characters. MessageMaxLength = 1024 // MessageTitleMaxLength is the max title number of characters. MessageTitleMaxLength = 250 // MessageURLMaxLength is the max URL number of characters. MessageURLMaxLength = 512 // MessageURLTitleMaxLength is the max URL title number of characters. MessageURLTitleMaxLength = 100 // MessageMaxAttachementByte is the max attachement size in byte. MessageMaxAttachementByte = 2621440 )
API limitations.
const ( PriorityLowest = -2 PriorityLow = -1 PriorityNormal = 0 PriorityHigh = 1 PriorityEmergency = 2 )
Message priorities
const ( SoundPushover = "pushover" SoundBike = "bike" SoundBugle = "bugle" SoundCashRegister = "cashregister" SoundClassical = "classical" SoundCosmic = "cosmic" SoundFalling = "falling" SoundGamelan = "gamelan" SoundIncoming = "incoming" SoundIntermission = "intermission" SoundMagic = "magic" SoundMechanical = "mechanical" SoundPianobar = "pianobar" SoundSiren = "siren" SoundSpaceAlarm = "spacealarm" SoundTugBoat = "tugboat" SoundAlien = "alien" SoundClimb = "climb" SoundPersistent = "persistent" SoundEcho = "echo" SoundUpDown = "updown" SoundNone = "none" )
Sounds
Variables ¶
var ( ErrHTTPPushover = errors.New("pushover: http error") ErrEmptyToken = errors.New("pushover: empty API token") ErrEmptyURL = errors.New("pushover: empty URL, URLTitle needs an URL") ErrEmptyRecipientToken = errors.New("pushover: empty recipient token") ErrInvalidRecipientToken = errors.New("pushover: invalid recipient token") ErrInvalidRecipient = errors.New("pushover: invalid recipient") ErrInvalidHeaders = errors.New("pushover: invalid headers in server response") ErrInvalidPriority = errors.New("pushover: invalid priority") ErrInvalidToken = errors.New("pushover: invalid API token") ErrMessageEmpty = errors.New("pushover: message empty") ErrMessageTitleTooLong = errors.New("pushover: message title too long") ErrMessageTooLong = errors.New("pushover: message too long") ErrMessageAttachementTooLarge = errors.New("pushover: message attachement is too large") ErrMessageURLTitleTooLong = errors.New("pushover: message URL title too long") ErrMessageURLTooLong = errors.New("pushover: message URL too long") ErrMissingAttachement = errors.New("pushover: missing attachement") ErrMissingEmergencyParameter = errors.New("pushover: missing emergency parameter") ErrInvalidDeviceName = errors.New("pushover: invalid device name") ErrEmptyReceipt = errors.New("pushover: empty receipt") )
Pushover custom errors.
var APIEndpoint = "https://api.pushover.net/1"
APIEndpoint is the API base URL for any request.
Functions ¶
This section is empty.
Types ¶
type Limit ¶
type Limit struct { // Total number of messages you can send during a month. Total int // Remaining number of messages you can send until the next reset. Remaining int // NextReset is the time when all the app counters will be reseted. NextReset time.Time }
Limit represents the limitation of the application. This information is fetched when posting a new message.
Headers example: X-Limit-App-Limit: 7500 X-Limit-App-Remaining: 7496 X-Limit-App-Reset: 1393653600
type Message ¶
type Message struct { // Required Message string // Optional Title string Priority int URL string URLTitle string Timestamp int64 Retry time.Duration Expire time.Duration CallbackURL string DeviceName string Sound string HTML bool // contains filtered or unexported fields }
Message represents a pushover message.
func NewMessageWithTitle ¶
NewMessageWithTitle returns a simple new message with a title.
type Pushover ¶
type Pushover struct {
// contains filtered or unexported fields
}
Pushover is the representation of an app using the pushover API.
func (*Pushover) CancelEmergencyNotification ¶
CancelEmergencyNotification helps stop a notification retry in case of a notification with an Emergency priority before reaching the expiration time. It requires the response receipt in order to stop the right notification.
func (*Pushover) GetReceiptDetails ¶
func (p *Pushover) GetReceiptDetails(receipt string) (*ReceiptDetails, error)
GetReceiptDetails return detailed informations about a receipt. This is used used to check the acknowledged status of an Emergency notification.
func (*Pushover) GetRecipientDetails ¶
func (p *Pushover) GetRecipientDetails(recipient *Recipient) (*RecipientDetails, error)
GetRecipientDetails allows to check if a recipient exists, if it's a group and the devices associated to this recipient. It returns an ErrInvalidRecipient if the recipient is not valid in the Pushover API.
type ReceiptDetails ¶
type ReceiptDetails struct { Status int Acknowledged bool AcknowledgedBy string Expired bool CalledBack bool ID string AcknowledgedAt *time.Time LastDeliveredAt *time.Time ExpiresAt *time.Time CalledBackAt *time.Time }
ReceiptDetails represents the receipt informations in case of emergency priority.
func (*ReceiptDetails) UnmarshalJSON ¶
func (r *ReceiptDetails) UnmarshalJSON(data []byte) error
UnmarshalJSON is a custom unmarshal function to handle timestamps and boolean as int and convert them to the right type.
type Recipient ¶
type Recipient struct {
// contains filtered or unexported fields
}
Recipient represents the a recipient to notify.
func NewRecipient ¶
NewRecipient is the representation of the recipient to notify.
type RecipientDetails ¶
type RecipientDetails struct { Status int `json:"status"` Group int `json:"group"` Devices []string `json:"devices"` RequestID string `json:"request"` Errors Errors `json:"errors"` }
RecipientDetails represents the receipt informations in case of emergency priority.