Created
November 26, 2018 03:59
-
-
Save nukosuke/be3e455c88539a83bcaeae0d4acbd151 to your computer and use it in GitHub Desktop.
go-zendesk Zendesk API Acc test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/nukosuke/go-zendesk/zendesk" | |
"net/http" | |
"os" | |
) | |
func main() { | |
httpClient := &http.Client{} | |
cred := zendesk.NewAPITokenCredential(os.Getenv("ZD_EMAIL"), os.Getenv("ZD_TOKEN")) | |
client, err := zendesk.NewClient(httpClient) | |
if err != nil { | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
if err = client.SetSubdomain(os.Getenv("ZD_SUBDOMAIN")); err != nil { | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
client.SetCredential(cred) | |
triggers, _, err := client.GetTriggers() | |
if err != nil { | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
fmt.Println(triggers) | |
ticketFields, page, err := client.GetTicketFields() | |
if err != nil { | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
fmt.Println(ticketFields) | |
ticketForms, _, err := client.GetTicketForms() | |
if err != nil { | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
fmt.Println("===== page has next") | |
fmt.Println(page.HasNext()) | |
fmt.Println(ticketForms) | |
client.CreateTicketField(zendesk.TicketField{Type: "text", Title: "Age"}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment