Documentation ¶
Overview ¶
Example ¶
package main import ( "log" "github.com/MEDIGO/go-zendesk/zendesk" ) func main() { client, err := zendesk.NewClient("domain", "username", "password") if err != nil { log.Fatal(err) } ticket, err := client.ShowTicket(1) if err != nil { log.Fatal(err) } log.Printf("Requester ID is: %d", *ticket.RequesterID) }
Output:
Index ¶
- func Bool(b bool) *bool
- func Int(i int64) *int64
- func String(s string) *string
- type APIError
- type APIErrorDetail
- type APIPayload
- type Attachment
- type Client
- type CustomField
- type ListOptions
- type ListUsersOptions
- type Locale
- type MiddlewareFunction
- type Organization
- type OrganizationMembership
- type RequestFunction
- type Ticket
- type TicketComment
- type TicketField
- type Upload
- type User
- type UserIdentity
- type Via
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIError ¶
type APIError struct { Response *http.Response Type *string `json:"error,omitmepty"` Description *string `json:"description,omitempty"` Details *map[string][]*APIErrorDetail `json:"details,omitempty"` }
APIError represents an error response returnted by the API.
type APIErrorDetail ¶
type APIErrorDetail struct { Type *string `json:"error,omitempty"` Description *string `json:"description,omitempty"` }
APIErrorDetail represents a detail about an APIError.
func (*APIErrorDetail) Error ¶
func (e *APIErrorDetail) Error() string
type APIPayload ¶
type APIPayload struct { Attachment *Attachment `json:"attachment"` Attachments []Attachment `json:"attachments"` Comment *TicketComment `json:"comment,omitempty"` Comments []TicketComment `json:"comments,omitempty"` Identity *UserIdentity `json:"identity,omitempty"` Identities []UserIdentity `json:"identities,omitempty"` Locale *Locale `json:"locale,omitempty"` Locales []Locale `json:"locales,omitempty"` Organization *Organization `json:"organization,omitempty"` OrganizationMembership *OrganizationMembership `json:"organization_membership,omitempty"` OrganizationMemberships []OrganizationMembership `json:"organization_memberships,omitempty"` Organizations []Organization `json:"organizations,omitempty"` Tags []string `json:"tags,omitempty"` Ticket *Ticket `json:"ticket,omitempty"` TicketField *TicketField `json:"ticket_field,omitempty"` TicketFields []TicketField `json:"ticket_fields,omitempty"` Tickets []Ticket `json:"tickets,omitempty"` Upload *Upload `json:"upload,omitempty"` User *User `json:"user,omitempty"` Users []User `json:"users,omitempty"` }
APIPayload represents the payload of an API call.
type Attachment ¶
type Attachment struct { ID *int64 `json:"id,omitempty"` FileName *string `json:"file_name,omitempty"` ContentURL *string `json:"content_url,omitempty"` ContentType *string `json:"content_type,omitempty"` Size *int64 `json:"size,omitempty"` Inline *bool `json:"inline,omitempty"` }
Attachment represents a Zendesk attachment for tickets and forum posts.
Zendesk Core API docs: https://developer.zendesk.com/rest_api/docs/core/attachments
type Client ¶
type Client interface { WithHeader(name, value string) Client AddUserTags(int64, []string) ([]string, error) BatchUpdateManyTickets([]Ticket) error BulkUpdateManyTickets([]int64, *Ticket) error CreateIdentity(int64, *UserIdentity) (*UserIdentity, error) CreateOrganization(*Organization) (*Organization, error) CreateOrganizationMembership(*OrganizationMembership) (*OrganizationMembership, error) CreateOrUpdateUser(*User) (*User, error) CreateTicket(*Ticket) (*Ticket, error) CreateUser(*User) (*User, error) DeleteIdentity(int64, int64) error DeleteOrganization(int64) error DeleteTicket(int64) error DeleteUser(int64) (*User, error) DeleteOrganizationMembershipByID(int64) error ListIdentities(int64) ([]UserIdentity, error) ListLocales() ([]Locale, error) ListOrganizationMembershipsByUserID(id int64) ([]OrganizationMembership, error) ListOrganizations(*ListOptions) ([]Organization, error) ListOrganizationUsers(int64, *ListUsersOptions) ([]User, error) ListRequestedTickets(int64) ([]Ticket, error) ListTicketComments(int64) ([]TicketComment, error) ListTicketFields() ([]TicketField, error) ListTicketIncidents(int64) ([]Ticket, error) SearchUsers(string) ([]User, error) ShowIdentity(int64, int64) (*UserIdentity, error) ShowLocale(int64) (*Locale, error) ShowLocaleByCode(string) (*Locale, error) ShowManyUsers([]int64) ([]User, error) ShowOrganization(int64) (*Organization, error) ShowTicket(int64) (*Ticket, error) ShowUser(int64) (*User, error) UpdateIdentity(int64, int64, *UserIdentity) (*UserIdentity, error) UpdateOrganization(int64, *Organization) (*Organization, error) UpdateTicket(int64, *Ticket) (*Ticket, error) UpdateUser(int64, *User) (*User, error) UploadFile(string, *string, io.Reader) (*Upload, error) }
Client describes a client for the Zendesk Core API.
func NewClient ¶
func NewClient(domain, username, password string, middleware ...MiddlewareFunction) (Client, error)
NewClient creates a new Client.
You can use either a user email/password combination or an API token. For the latter, append /token to the email and use the API token as a password
func NewEnvClient ¶
func NewEnvClient(middleware ...MiddlewareFunction) (Client, error)
NewEnvClient creates a new Client configured via environment variables.
Three environment variables are required: ZENDESK_DOMAIN, ZENDESK_USERNAME and ZENDESK_PASSWORD they will provide parameters to the NewClient function
func NewURLClient ¶
func NewURLClient(endpoint, username, password string, middleware ...MiddlewareFunction) (Client, error)
NewURLClient is like NewClient but accepts an explicit end point instead of a Zendesk domain.
type CustomField ¶
type CustomField struct { ID *int64 `json:"id"` Value interface{} `json:"value"` }
type ListOptions ¶
type ListOptions struct { // Sets the page of results to retrieve. Page int `url:"page,omitempty"` // Sets the number of results to include per page. PerPage int `url:"per_page,omitempty"` }
ListOptions specifies the optional parameters for the list methods that support pagination.
Zendesk Core API doscs: https://developer.zendesk.com/rest_api/docs/core/introduction#pagination
type ListUsersOptions ¶
type ListUsersOptions struct { ListOptions Role []string `url:"role"` PermissionSet int64 `url:"permision_set"` }
ListUsersOptions specifies the optional parameters for the list users methods.
type Locale ¶
type Locale struct { ID *int64 `json:"id,omitempty"` URL *string `json:"url,omitempty"` Locale *string `json:"locale,omitempty"` Name *string `json:"name,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` }
Locale represents an Zendesk translation locale.
Zendesk Core API docs: https://developer.zendesk.com/rest_api/docs/core/locales
type MiddlewareFunction ¶
type MiddlewareFunction func(RequestFunction) RequestFunction
type Organization ¶
type Organization struct { ID *int64 `json:"id,omitempty"` URL *string `json:"url,omitempty"` ExternalID *string `json:"external_id,omitempty"` Name *string `json:"name,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` DomainNames *[]string `json:"domain_names,omitempty"` Details *string `json:"details,omitempty"` Notes *string `json:"notes,omitempty"` GroupID *int64 `json:"group_id,omitempty"` OrganizationFields map[string]interface{} `json:"organization_fields,omitempty"` }
Organization represents a Zendesk organization.
Zendesk Core API docs: https://developer.zendesk.com/rest_api/docs/core/organizations
type OrganizationMembership ¶
type OrganizationMembership struct { ID *int64 `json:"id,omitempty"` URL *string `json:"url,omitempty"` UserID *int64 `json:"user_id,omitempty"` OrganizationID *int64 `json:"organization_id,omitempty"` Default *bool `json:"default,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` }
OrganizationMembership represents a Zendesk association between an org and a user.
Zendesk Core API docs: https://developer.zendesk.com/rest_api/docs/core/organization_memberships
type Ticket ¶
type Ticket struct { ID *int64 `json:"id,omitempty"` URL *string `json:"url,omitempty"` ExternalID *string `json:"external_id,omitempty"` Type *string `json:"type,omitempty"` Subject *string `json:"subject,omitempty"` RawSubject *string `json:"raw_subject,omitempty"` Description *string `json:"description,omitempty"` Comment *TicketComment `json:"comment,omitempty"` Priority *string `json:"priority,omitempty"` Status *string `json:"status,omitempty"` Recipient *string `json:"recipient,omitempty"` RequesterID *int64 `json:"requester_id,omitempty"` Requester *User `json:"requester,omitempty"` SubmitterID *int64 `json:"submitter_id,omitempty"` AssigneeID *int64 `json:"assignee_id,omitempty"` OrganizationID *int64 `json:"organization_id,omitempty"` GroupID *int64 `json:"group_id,omitempty"` CollaboratorIDs []int64 `json:"collaborator_ids,omitempty"` ForumTopicID *int64 `json:"forum_topic_id,omitempty"` ProblemID *int64 `json:"problem_id,omitempty"` HasIncidents *bool `json:"has_incidents,omitempty"` DueAt *time.Time `json:"due_at,omitempty"` Tags []string `json:"tags,omitempty"` Via *Via `json:"via,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` CustomFields []CustomField `json:"custom_fields,omitempty"` BrandID *int64 `json:"brand_id,omitempty"` TicketFormID *int64 `json:"ticket_form_id,omitempty"` AdditionalTags []string `json:"additional_tags,omitempty"` RemoveTags []string `json:"remove_tags,omitempty"` }
Ticket represents a Zendesk Ticket.
Zendesk Core API docs: https://developer.zendesk.com/rest_api/docs/core/tickets
type TicketComment ¶
type TicketComment struct { ID *int64 `json:"id,omitempty"` Type *string `json:"type,omitempty"` Body *string `json:"body,omitempty"` HTMLBody *string `json:"html_body,omitempty"` Public *bool `json:"public,omitempty"` AuthorID *int64 `json:"author_id,omitempty"` Attachments []Attachment `json:"attachments,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` Uploads []string `json:"uploads,omitempty"` }
TicketComment represents a comment on a Ticket.
Zendesk Core API docs: https://developer.zendesk.com/rest_api/docs/core/ticket_comments
type TicketField ¶
type TicketField struct { ID *int64 `json:"id,omitempty"` Type *string `json:"string,omitempty"` Title *string `json:"title,omitempty"` Description *string `json:"description,omitempty"` Position *int64 `json:"position,omitempty"` Active *bool `json:"active,omitempty"` VisibleInPortal *bool `json:"visible_in_portal,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` }
type Upload ¶
type Upload struct { Token *string `json:"token"` Attachment *Attachment `json:"attachment"` Attachments []Attachment `json:"attachments"` }
Upload represents a Zendesk file upload.
type User ¶
type User struct { ID *int64 `json:"id,omitempty"` URL *string `json:"url,omitempty"` Name *string `json:"name,omitempty"` ExternalID *string `json:"external_id,omitempty"` Alias *string `json:"alias,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` Active *bool `json:"active,omitempty"` Verified *bool `json:"verified,omitempty"` Locale *string `json:"locale,omitempty"` LocaleID *int64 `json:"locale_id,omitempty"` TimeZone *string `json:"time_zone,omitempty"` LastLoginAt *time.Time `json:"last_login_at,omitempty"` Email *string `json:"email,omitempty"` Phone *string `json:"phone,omitempty"` Signature *string `json:"signature,omitempty"` Details *string `json:"details,omitempty"` Notes *string `json:"notes,omitempty"` OrganizationID *int64 `json:"organization_id,omitempty"` Role *string `json:"role,omitempty"` CustomerRoleID *int64 `json:"custom_role_id,omitempty"` Moderator *bool `json:"moderator,omitempty"` TicketRestriction *string `json:"ticket_restriction,omitempty"` OnlyPrivateComments *bool `json:"only_private_comments,omitempty"` Tags []string `json:"tags,omitempty"` RestrictedAgent *bool `json:"restricted_agent,omitempty"` Suspended *bool `json:"suspended,omitempty"` UserFields map[string]interface{} `json:"user_fields,omitempty"` }
User represents a Zendesk user.
Zendesk Core API docs: https://developer.zendesk.com/rest_api/docs/core/users#content
type UserIdentity ¶
type UserIdentity struct { ID *int64 `json:"id,omitempty"` URL *string `json:"url,omitempty"` UserID *int64 `json:"user_id,omitempty"` Type *string `json:"type,omitempty"` Value *string `json:"value,omitempty"` Verified *bool `json:"verified,omitempty"` Primary *bool `json:"primary,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` UndeliverableCount *int64 `json:"undeliverable_count,omitempty"` DeliverableState *string `json:"deliverable_state,omitempty"` }
UserIdentity represents a Zendesk user identity.
Zendesk Core API docs: https://developer.zendesk.com/rest_api/docs/core/user_identities