Documentation
¶
Index ¶
- type Client
- func (c *Client) AddComment(ticketID int64, commentBody string, public bool) error
- func (c *Client) CreateTicket(requesterEmail, subject, commentBody string, fields map[string]string) (int64, error)
- func (c *Client) FindTickets(matchFields map[string]string, status string) (map[int64]map[string]string, error)
- func (c *Client) UpdateTicketStatus(ticketID int64, status string, commentBody string, public bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Zendesk client that allows you to create tickets, search for tickets, and add comments to tickets via the Zendesk REST API. It uses basic authentication with an API token.
func NewClient ¶
NewClient creates a new Zendesk client with the provided baseURL, token, and tokenEmail, and a name to field id mapping. baseURL is your Zendesk URL with the scheme included, e.g. "https://yourdomain.zendesk.com". Token is an API token generated from the Zendesk Admin UI. The tokenEmail is the email address of the Zendesk user that created the token. The nameToFieldID must contain the display names and corresponding IDs of the custom fields you want to use in your tickets, this allows you to refer to custom fields by string names instead of numeric IDs when working with tickets.
func (*Client) AddComment ¶
AddComment posts the comment body to the specified ticket. The comment is added as a public or private comment based on the provided boolean value. An error is returned if the request fails.
func (*Client) CreateTicket ¶
func (c *Client) CreateTicket(requesterEmail, subject, commentBody string, fields map[string]string) (int64, error)
CreateTicket creates a new Zendesk ticket with the provided requester email, subject, initial comment body, and custom fields. It returns the ID of the created ticket or an error if the request fails. The custom fields should be provided as a map where the keys are the display names of the custom fields and the values are the desired values for those fields. The method will convert the display names to their corresponding field IDs using the nameToFieldID map provided when creating the Client. If a custom field name is unknown, an error will be returned.
func (*Client) FindTickets ¶
func (c *Client) FindTickets(matchFields map[string]string, status string) (map[int64]map[string]string, error)
FindTickets returns all tickets whose custom fields match the required matchFields and optional status. The matchFields map should contain the display names of the custom fields as keys and the desired values as values. The method returns a map where the keys are ticket IDs and the values are maps of custom field names to their values. If no matchFields are supplied, an error is returned. If a custom field name is unknown, an error is returned.
func (*Client) UpdateTicketStatus ¶ added in v0.20250825.0
func (c *Client) UpdateTicketStatus(ticketID int64, status string, commentBody string, public bool) error
UpdateTicketStatus updates the status of the specified ticket to the provided status and adds a comment with the provided body. The comment is added as a public or private comment based on the provided boolean value. An error is returned if the request fails or if the provided status is invalid.