go-deadmanssnitch is a Go client library for the Dead Man's Snitch API.
Make sure you have a working Go environment. To install, simply run:
go get github.com/PremiereGlobal/go-deadmanssnitch
package main
import (
"github.com/PremiereGlobal/go-deadmanssnitch"
)
var apiKey = "" // Set your api key here
func main() {
client := deadmanssnitch.NewClient(apiKey)
...
}
For more information, read the godoc package documentation.
var snitchToken = "" // Set your snitch token here
err := client.CheckIn(snitchToken)
if err != nil {
panic(err)
}
snitches, err := client.ListSnitches([]string{})
if err != nil {
panic(err)
}
snitch := deadmanssnitch.Snitch {
Name: "testSnitch",
Interval: "hourly",
AlertType: "basic",
Tags: []string{"test"},
Notes: "This is an example snitch",
}
createdSnitch, err := client.CreateSnitch(&snitch)
if err != nil {
panic(err)
}
Tests will validate API calls by creating a test snitch, checking in and updating the snitch using all of the methods. It will then delete the snitch after waiting wait
seconds (to allow for manual verification).
go test -v --args -apikey=<apiKey> -wait 30