zendesk-go
Zendesk API client library for Go.
Getting Started
Install
go get github.com/aaronellington/zendesk-go
Create new connection
[!NOTE]
You will need to set your Zendesk Credentials in your environment before the below example will work.
package main
import (
"context"
"log"
"os"
"github.com/aaronellington/zendesk-go/zendesk"
)
func main() {
ctx := context.Background()
z := zendesk.NewService(
os.Getenv("ZENDESK_DEMO_SUBDOMAIN"),
zendesk.AuthenticationToken{
Email: os.Getenv("ZENDESK_DEMO_EMAIL"),
Token: os.Getenv("ZENDESK_DEMO_TOKEN"),
},
zendesk.ChatCredentials{
ClientID: os.Getenv("ZENDESK_DEMO_CHAT_CLIENT_ID"),
ClientSecret: os.Getenv("ZENDESK_DEMO_CHAT_CLIENT_SECRET"),
},
// Logger is optional, see implementation to see how to add your custom logger here
zendesk.WithLogger(log.New(os.Stdout, "Zendesk API - ", log.LstdFlags)),
// Optionally set http.RoundTripper - this is helpful when writing tests
zendesk.WithRoundTripper(customRoundTripper),
)
tags, err := support.Tickets().AddTags(ctx, 6170, zendesk.Tags{
"foobar",
})
if err != nil {
log.Fatal(err)
}
log.Printf("%+v", tags)
}