Skip to content
/ tapd Public

The Go-Tapd-SDK is a Go client library for accessing the Tapd API.

License

Notifications You must be signed in to change notification settings

go-tapd/tapd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Go-Tapd-SDK

Supported Go Versions Package Version GoDoc codecov Go Report Card lint tests MIT license

The Go-Tapd-SDK is a Go client library for accessing the Tapd API.

⚠️⚠️ This is currently still a non-stable version; please use it with caution.

If you encounter any issues, you are welcome to submit an issue.

📥 Installation

go get github.com/go-tapd/tapd

✨ Features

see features.md

🔧 Usage

API Service

package main

import (
	"context"
	"log"

	"github.com/go-tapd/tapd"
)

func main() {
	client, err := tapd.NewClient("username", "password")
	if err != nil {
		log.Fatal(err)
	}

	// example: get labels
	labels, _, err := client.LabelService.GetLabels(context.Background(), &tapd.GetLabelsRequest{
		WorkspaceID: tapd.Ptr(123456),
	})
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("labels: %+v", labels)
}

Webhook Server Example

package main

import (
	"context"
	"log"
	"net/http"

	"github.com/go-tapd/tapd/webhook"
)

type StoreUpdateListener struct{}

func (l *StoreUpdateListener) OnStoryUpdate(ctx context.Context, event *webhook.StoryUpdateEvent) error {
	log.Printf("StoreUpdateListener: %+v", event)
	return nil
}

func main() {
	dispatcher := webhook.NewDispatcher(
		webhook.WithRegisters(&StoreUpdateListener{}),
	)
	dispatcher.Registers(&StoreUpdateListener{})

	srv := http.NewServeMux()
	srv.HandleFunc("/webhook", func(w http.ResponseWriter, r *http.Request) {
		log.Println("Received webhook request")
		if err := dispatcher.DispatchRequest(r); err != nil {
			log.Println(err)
		}
		w.Write([]byte("ok"))
	})

	http.ListenAndServe(":8080", srv)
}

📜 License

The MIT License (MIT). Please see License File for more information.