Documentation ¶
Index ¶
- Constants
- type Client
- func (p *Client) CloseWebsocket()
- func (p Client) DeleteMessagesByID(highestID int) error
- func (p Client) DeleteOldMessages(messages []Message) error
- func (p Client) Device() string
- func (p Client) GetMessages() ([]Message, error)
- func (p *Client) GetStatus() (bool, bool)
- func (p *Client) ListenForNotifications() error
- func (p *Client) Login(email string, password string) error
- func (p *Client) Login2FA(email string, password string, twofacode string) error
- func (p *Client) RegisterDevice(name string) error
- func (p *Client) RestoreDevice(devid string)
- func (p *Client) RestoreLogin(secret string, userid string)
- func (p Client) SendRequest(endpoint string, data url.Values) (*http.Response, error)
- func (p *Client) SetAppInfo(appName string, appVersion string)
- func (p Client) User() (userID string, secret string)
- type ErrorFrameError
- type Message
- type Missing2FAError
Constants ¶
const LIBRARY_NAME string = "go-poclient"
const LIBRARY_VERSION string = "1.2.0"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Messages chan Message // contains filtered or unexported fields }
Client represents the main Pushover Client. The Messages channel works in conjunction with ListenForNotifications, which pushes incoming Messages into this channel.
func (*Client) CloseWebsocket ¶
func (p *Client) CloseWebsocket()
CloseWebsocket forcefully closes a open websocket connection, if one exists This also causes a running ListenForNotifications to return an error, which you can use to reconnect
func (Client) DeleteMessagesByID ¶
DeleteMessagesByID marks all messages below the given relative ID as read which means they will not be transmitted again by the API https://pushover.net/api/client#delete
func (Client) DeleteOldMessages ¶
DeleteOldMessages finds the hightest relative ID and calls DeleteMessagesByID This action is permanent, so you need to save the messages if you want to keep them
func (Client) GetMessages ¶
GetMessages retrieves all new messages from the API. Usually you call DeleteOldMessages right afterwards to clear all pending notifications
func (*Client) ListenForNotifications ¶
ListenForNotifications connects to the WebSocket endpoint and waits for incoming notifications This function is designed to run in a goroutine If no keep-alive packet is received for one minute, the function exits with a timeout error (net.Error). Note: This function clears all notifications after receiving them, so you should pull messages from the Messages channel and save them if you want to keep them
func (*Client) Login ¶
Login retrieves user id and user secret. After successfully logging, you should retrieve the user id and secret by calling User() and store them somewhere safe.
func (*Client) RegisterDevice ¶
RegisterDevice registers a new device after logging in. The name parameter is a human readable short name (up to 25 characters long) for the device. After successfully registering the device you should retrieve the device_id by calling Device() and store it in a safe place.
func (*Client) RestoreDevice ¶
RestoreDevice sets device ID from a previous device registration
func (*Client) RestoreLogin ¶
RestoreLogin sets user ID and secret to access the API from a previous login
func (Client) SendRequest ¶
func (*Client) SetAppInfo ¶
SetAppInfo sets information about the calling app, which is sent with every request so that pushover can identify the applications using their API
type ErrorFrameError ¶
type ErrorFrameError struct{}
func (*ErrorFrameError) Error ¶
func (e *ErrorFrameError) Error() string
type Message ¶
type Message struct { RelativeID int `json:"id"` UniqueID int `json:"umid"` Title string `json:"title"` Text string `json:"message"` AppName string `json:"app"` AppID int `json:"aid"` IconID string `json:"icon"` Timestamp int64 `json:"date"` Date time.Time `json:"-"` Priority int `json:"priority"` Sound string `json:"sound"` URL string `json:"url"` URLTitle string `json:"url_title"` Acknowledged convertibleBoolean `json:"acked"` ReceiptCode string `json:"receipt"` ContainsHTML convertibleBoolean `json:"html"` }
Message represents a message loaded from the API The fields are documented here: https://pushover.net/api/client#download
type Missing2FAError ¶
type Missing2FAError struct{}
func (*Missing2FAError) Error ¶
func (e *Missing2FAError) Error() string