Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Latest commit

 

History

History
48 lines (36 loc) · 1 KB

README.md

File metadata and controls

48 lines (36 loc) · 1 KB

Freshdesk API (Go, golang)

Basic API submitting a ticket to Freshdesk.com

How to use

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)
	}
}

Conform library compatibility

Ticket struct fields work with the optional conform library.