Basic API submitting a ticket to Freshdesk.com
import (
"fmt"
"os"
"github.com/leebenson/conform"
"github.com/smallpdf/freshdesk"
)
func main() {
client, err := freshdesk.NewClient("your-domain", "your-api-key")
if err != nil {
fmt.Printf("Could not create client: %s\n", err)
os.Exit(1)
}
ticket := &Ticket{
Email: "[email protected]",
Name: "your name",
Subject: "this is a test",
Type: freshdesk.Question,
Description: "the content of the ticket would go here",
Status: freshdesk.Open,
Priority: freshdesk.Medium,
Source: freshdesk.Portal,
}
// optionally check the ticket with conform
conform.Strings(ticket)
if _, err := client.CreateTicket(ticket); err != nil {
fmt.Printf("failed to create ticket: %s", err)
os.Exit(1)
}
}
Ticket struct fields work with the optional conform library.