Documentation ¶
Overview ¶
Package pushover implements access to the Pushover API
This documentation can be considered a supplement to the official Pushover API documentation at https://pushover.net/api. Refer to that official documentation for the details on how to us these library functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrInvalidRequest ¶
type ErrInvalidRequest struct{}
ErrInvalidRequest indicates invalid request data was sent to a library function
func (*ErrInvalidRequest) Error ¶ added in v1.0.6
func (ir *ErrInvalidRequest) Error() string
type ErrInvalidResponse ¶
type ErrInvalidResponse struct{}
ErrInvalidResponse indicates an invalid response body was received from the Pushover API
func (*ErrInvalidResponse) Error ¶ added in v1.0.6
func (ir *ErrInvalidResponse) Error() string
type MessageRequest ¶
type MessageRequest struct { // The URL for the Pushover REST API POST. // // Leave this empty unless you wish to override the URL. PushoverURL string // Pushover API token Token string // The user's token for message delivery User string // The message sent to the user Message string // Message title Title string // Embedded URL URL string // The displayed text for the URL // // If the field URL is missing, the title will be // displayed as normal text URLTitle string // Enable HTML formatting of the message // // See the Pushover REST API documentation for allowed tags HTML string // Enable monospace formatting of the message Monospace string // Sound name for the sound on the user's device // // See the Pushover REST API documentation for valid // values. Invalid sound names will not be rejected by //Pushover Sound string // The device to send the message to rather than all the // user's devices. // // Devices not registered will not be rejected by Pushover // and will therefore fail silently. Device string // Priority number for the message // // See the Pushover REST API documentation for values and // what they mean // // Invalid priority numbers will be rejected by Pushover Priority string // How often in seconds the Pushover servers will send // the same notification to the user // // Must be set when Priority is set to "2" and must // have a value of at least 30 seconds between retries Retry string // How many seconds your notification will continue to // be retried for (every retry seconds) // // Must be set when Priority is set to "2" and must // have a maximum value of at most 10800 seconds // (3 hours) Expire string // Callback url for the message // // Optional be set when Priority is set to "2" Callback string // Unix timestamp for the message rather than the time // the message was received by the Pushover REST API // // Invalid timestamps will not be rejected by Pushover Timestamp string // Reader for image (attachment) data ImageReader io.Reader // Optional image name // // Leave blank to default to image.jpg ImageName string }
MessageRequest is the data for the POST to the Pushover REST API. Some fields in this request should contain numbers but the Pushover API parameters are strings. There is no validation performed for these fields. If invalid data is submitted to the Pushover API, it will be rejected with an appropriate error.
See the Pushover API documentation for more information on these parameters.
type MessageResponse ¶
type MessageResponse struct { // Original response body from POST ResponseBody string // HTTP Status string HTTPStatus string // HTTP Status Code HTTPStatusCode int // The status as returned by the Pushover API. // // Value of 1 indicates 200 response received. // Any other value indicates an error with the // input. APIStatus int // ID assigned to the request by Pushover Request string // Receipt // // When a priority of 2 is given, a receipt field // is returned Receipt string // List of errors returned // // Empty if no errors Errors []string // Map of parameters and corresponding errors // // Empty if no errors ErrorParameters map[string]string }
MessageResponse is the response from this API. It is read from the body of the Pushover REST API response and translated to this response structure.
For access to the original, untranslated response, access the ResponseBody field.
func Message ¶
func Message(request MessageRequest) (*MessageResponse, error)
Message will submit a request to the Pushover Message API. This function will send a message, triggering a notification on a user's device or a group's devices.
resp, err := pushover.Message(pushover.MessageRequest{ Token: token, User: user, Message: message, })
func MessageContext ¶
func MessageContext(ctx context.Context, request MessageRequest) (*MessageResponse, error)
MessageContext will submit a request to the Pushover Message API. This function will send a message, triggering a notification on a user's device or a group's devices.
resp, err := pushover.MessageContext(context.Background(), pushover.MessageRequest{ Token: token, User: user, Message: message, })
type ValidateRequest ¶
type ValidateRequest struct { // The URL for the Pushover REST API POST. // // Leave this empty unless you wish to override the URL. PushoverURL string // Pushover API token Token string // The user's token to validate User string // User device to validate (optional) Device string }
ValidateRequest is the data to POST to the Pushover REST API. See the Pushover Validate API documentation for more information on these parameters.
type ValidateResponse ¶
type ValidateResponse struct { // Original response body from POST ResponseBody string // HTTP Status string HTTPStatus string // HTTP Status Code HTTPStatusCode int // The status as returned by the Pushover API. // // Value of 1 indicates 200 response received. // Any other value indicates an error with the // input. APIStatus int // This field is returned but not documented // by the Pushover Validate API Group int // ID assigned to the request by Pushover Request string // List of registered devices Devices []string // List of licensed platforms Licenses []string // List of errors returned // // Empty if no errors Errors []string // Map of parameters and corresponding errors // // Empty if no errors ErrorParameters map[string]string }
ValidateResponse is the response from this API. It is read from the body of the Pushover REST API response and translated to this response structure.
For access to the original, untranslated response, access the ResponseBody field.
func Validate ¶
func Validate(request ValidateRequest) (*ValidateResponse, error)
Validate will submit a POST request to the Pushover Validate API This function will check a user or group token to determine if it is valid.
resp, err := pushover.Validate(pushover.ValidateRequest{ Token: token, User: user, })
func ValidateContext ¶
func ValidateContext(ctx context.Context, request ValidateRequest) (*ValidateResponse, error)
ValidateContext will submit a POST request to the Pushover Validate API. This function will check a user or group token to determine if it is valid.
resp, err := pushover.ValidateContext(context.Background(), pushover.ValidateRequest{ Token: token, User: user, })