Documentation
¶
Index ¶
- Variables
- func Listen(deviceID string, secret string, ml MessageCallback) error
- func ListenWithReconnect(deviceID string, secret string, ml MessageCallback) error
- type AuthorizedClient
- func (ac *AuthorizedClient) DeleteMessages(id int64) (*DeleteResponse, error)
- func (ac *AuthorizedClient) DownloadAndDeleteMessages() (*DownloadResponse, *DeleteResponse, error)
- func (ac *AuthorizedClient) DownloadMessages() (*DownloadResponse, error)
- func (ac *AuthorizedClient) GetAuthorizedListener(l LeveledLogger) *AuthorizedListener
- type AuthorizedListener
- type DeleteResponse
- type Device
- type DownloadResponse
- type Errors
- type LeveledLogger
- type Listener
- type LoginResponse
- type MessageCallback
- type Messages
- type PushoverClient
- func (pc *PushoverClient) DownloadAndDeleteMessages(secret, deviceID string) (*DownloadResponse, *DeleteResponse, error)
- func (pc *PushoverClient) GetApiURL() (url.URL, error)
- func (pc *PushoverClient) Login(username, password, twofa string) (*LoginResponse, error)
- func (pc *PushoverClient) Register(secret, name string) (*RegistrationResponse, error)
- type PushoverClientResponse
- type RegistrationResponse
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrWebsocketConnectFail = fmt.Errorf("error connecting to WebSocket") ErrWebsocketLoginFail = fmt.Errorf("error logging in to WebSocket") ErrWebsocketReadFail = fmt.Errorf("error reading from WebSocket") ErrNeedReconnect = fmt.Errorf("need to reconnect") ErrPermanentIssue = fmt.Errorf("permanent error") ErrSessionIssue = fmt.Errorf("session issue") )
View Source
var DefaultListener = &Listener{ Log: slog.New(slog.NewTextHandler(io.Discard, nil)), }
Functions ¶
func ListenWithReconnect ¶
func ListenWithReconnect(deviceID string, secret string, ml MessageCallback) error
Types ¶
type AuthorizedClient ¶
type AuthorizedClient struct {
UserSecret string
DeviceID string
*PushoverClient
}
func NewAuthorizedClient ¶
func NewAuthorizedClient(userSecret, deviceID string) *AuthorizedClient
func (*AuthorizedClient) DeleteMessages ¶
func (ac *AuthorizedClient) DeleteMessages(id int64) (*DeleteResponse, error)
func (*AuthorizedClient) DownloadAndDeleteMessages ¶
func (ac *AuthorizedClient) DownloadAndDeleteMessages() (*DownloadResponse, *DeleteResponse, error)
func (*AuthorizedClient) DownloadMessages ¶
func (ac *AuthorizedClient) DownloadMessages() (*DownloadResponse, error)
func (*AuthorizedClient) GetAuthorizedListener ¶
func (ac *AuthorizedClient) GetAuthorizedListener(l LeveledLogger) *AuthorizedListener
type AuthorizedListener ¶
type AuthorizedListener struct {
*AuthorizedClient
*Listener
}
func NewAuthorizedListener ¶
func NewAuthorizedListener(ac *AuthorizedClient, l LeveledLogger) *AuthorizedListener
func (*AuthorizedListener) Listen ¶
func (al *AuthorizedListener) Listen(ml MessageCallback) error
func (*AuthorizedListener) ListenWithReconnect ¶
func (al *AuthorizedListener) ListenWithReconnect(ml MessageCallback) error
type Device ¶
type Device struct {
Name string `json:"name"`
EncryptionEnabled bool `json:"encryption_enabled"`
DefaultSound string `json:"default_sound"`
AlwaysUseDefaultSound bool `json:"always_use_default_sound"`
DefaultHighPrioritySound string `json:"default_high_priority_sound"`
AlwaysUseDefaultHighPrioritySound bool `json:"always_use_default_high_priority_sound"`
DismissalSyncEnabled bool `json:"dismissal_sync_enabled"`
}
type DownloadResponse ¶
type DownloadResponse struct {
Messages []Messages `json:"messages"`
User User `json:"user"`
Device Device `json:"device"`
PushoverClientResponse
}
func DownloadMessages ¶
func DownloadMessages(api url.URL, secret, deviceID string) (*DownloadResponse, error)
func (*DownloadResponse) MaxID ¶
func (r *DownloadResponse) MaxID() int64
type LeveledLogger ¶
type LeveledLogger interface {
Error(string, ...interface{})
Info(string, ...interface{})
Debug(string, ...interface{})
Warn(string, ...interface{})
}
LeveledLogger is an interface for loggers or logger wrappers that support leveled logging. The methods take a message string and optional variadic key-value pairs.
type Listener ¶
type Listener struct {
Log LeveledLogger
}
func NewListener ¶
func NewListener(l LeveledLogger) *Listener
func (*Listener) Listen ¶
func (l *Listener) Listen(deviceID string, secret string, ml MessageCallback) error
func (*Listener) ListenWithReconnect ¶
func (l *Listener) ListenWithReconnect(deviceID string, secret string, ml MessageCallback) error
type LoginResponse ¶
type LoginResponse struct {
ID string `json:"id"`
Secret string `json:"secret"`
PushoverClientResponse
}
type MessageCallback ¶
type MessageCallback func() error
type Messages ¶
type Messages struct {
ID int64 `json:"id"`
IDStr string `json:"id_str"`
Message string `json:"message"`
App string `json:"app"`
Aid int `json:"aid"`
AidStr string `json:"aid_str"`
Icon string `json:"icon"`
Date int `json:"date"`
Priority int `json:"priority"`
Acked int `json:"acked"`
Umid int64 `json:"umid"`
UmidStr string `json:"umid_str"`
Title string `json:"title"`
DispatchedDate int `json:"dispatched_date"`
URL string `json:"url,omitempty"`
QueuedDate int `json:"queued_date,omitempty"`
}
type PushoverClient ¶
type PushoverClient struct {
APIURL string
}
func (*PushoverClient) DownloadAndDeleteMessages ¶
func (pc *PushoverClient) DownloadAndDeleteMessages(secret, deviceID string) (*DownloadResponse, *DeleteResponse, error)
func (*PushoverClient) Login ¶
func (pc *PushoverClient) Login(username, password, twofa string) (*LoginResponse, error)
func (*PushoverClient) Register ¶
func (pc *PushoverClient) Register(secret, name string) (*RegistrationResponse, error)
type PushoverClientResponse ¶
type PushoverClientResponse struct {
Status int `json:"status"`
Request string `json:"request"`
Errors Errors `json:"errors,omitempty"`
}
func (*PushoverClientResponse) Error ¶
func (r *PushoverClientResponse) Error() string
func (*PushoverClientResponse) IsValid ¶
func (r *PushoverClientResponse) IsValid() bool
type RegistrationResponse ¶
type RegistrationResponse struct {
ID string `json:"id"`
PushoverClientResponse
}
type User ¶
type User struct {
QuietHours bool `json:"quiet_hours"`
IsAndroidLicensed bool `json:"is_android_licensed"`
IsIosLicensed bool `json:"is_ios_licensed"`
IsDesktopLicensed bool `json:"is_desktop_licensed"`
Email string `json:"email"`
CreatedAt int `json:"created_at"`
FirstEmailAlias string `json:"first_email_alias"`
ShowTipjar string `json:"show_tipjar"`
ShowTeamAd string `json:"show_team_ad"`
}
Click to show internal directories.
Click to hide internal directories.