go-api-client

module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2018 License: MIT

README

Gotify Golang API-Client travis-badge

Generated with swagger-go.

Example

package main

import (
	"github.com/gotify/go-api-client/gotify"
	"net/url"
	"net/http"
	"log"
	"github.com/gotify/go-api-client/client/message"
	"github.com/gotify/server/model"
	"github.com/gotify/go-api-client/auth"
)

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.Version)

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

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

Update Instructions

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL