Files
go-pushover-client/client.go
T
Amrit Panesar bec477a678 Add client.go!
Signed-off-by: Amrit Panesar <apanesar@4195tech.com>
2015-09-01 17:17:39 -07:00

35 lines
605 B
Go

package go_pushover_client
import (
"http"
"net/url"
)
const (
pushoverURL = "https://api.pushover.net/1/messages.json"
)
type PushoverClient struct {
ApplicationToken string
}
func (p *PushoverClient) new(token string) {
p.ApplicationToken = token
}
func (p *PushoverClient) send(to string, message string, priority int32) {
payload := url.Values{
"token": {p.ApplicationToken},
"user": {to},
"message": {message},
"priority": {priority},
}
http.PostForm(pushoverURL, payload)
}
func NewPushoverClient(token string) {
out := PushoverClient{}
out.new(token)
return &out
}