Skip to content

A generated swagger client for making requests to gotify/server.

License

Notifications You must be signed in to change notification settings

gotify/go-api-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gotify Golang API-Client travis-badge

Generated with swagger-go.

Example

package main

import (
	"log"
	"net/http"
	"net/url"

	"github.com/gotify/go-api-client/v2/auth"
	"github.com/gotify/go-api-client/v2/client/message"
	"github.com/gotify/go-api-client/v2/gotify"
	"github.com/gotify/go-api-client/v2/models"
)

const (
	gotifyURL        = "https://push.gotify.url"
	applicationToken = "AxNVvRfx9.ZKCTj"
)

func main() {
	myURL, _ := url.Parse(gotifyURL)
	client := gotify.NewClient(myURL, &http.Client{})
	versionResponse, err := client.Version.GetVersion(nil)

	if err != nil {
		log.Fatal("Could not request version ", err)
		return
	}
	version := versionResponse.Payload
	log.Println("Found version", *version)

	params := message.NewCreateMessageParams()
	params.Body = &models.MessageExternal{
		Title:    "my title",
		Message:  "my message",
		Priority: 5,
	}
	_, err = client.Message.CreateMessage(params, auth.TokenAuth(applicationToken))

	if err != nil {
		log.Fatalf("Could not send message %v", err)
		return
	}
	log.Println("Message Sent!")
}

Update Instructions

  • Change version in Makefile.
  • Run make clean generate
  • Commit changes