Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/MEDIGO/go-zendesk

go 1.14
go 1.18

require (
github.com/google/go-querystring v1.0.0
Expand Down
7 changes: 5 additions & 2 deletions zendesk/mock_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions zendesk/org_membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ func (c *client) ListOrganizationMembershipsByUserID(id int64) ([]OrganizationMe
return out.OrganizationMemberships, err
}

// ListOrganizationMembershipsByOrganisationID returns all organization memberships for a specific organisation
//
// Zendesk Core API docs: https://developer.zendesk.com/rest_api/docs/core/organization_memberships#list-memberships
func (c *client) ListOrganizationMembershipsByOrganisationID(id int64) ([]OrganizationMembership, error) {
out := new(APIPayload)
err := c.get(fmt.Sprintf("/api/v2/organizations/%d/organization_memberships.json", id), out)
return out.OrganizationMemberships, err
}

// DeleteOrganizationMembership removes an organization membership
//
// Zendesk Core API docs: https://developer.zendesk.com/rest_api/docs/core/organization_memberships#delete-membership
Expand Down
2 changes: 1 addition & 1 deletion zendesk/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (c *client) SearchTickets(term string, options *ListOptions, filters ...Fil
queryString := fmt.Sprintf("type:%s ", ResultTypeTicket)
queryString += strings.Join(searchOptions.Search, " ")
if term != "" {
queryString = fmt.Sprintf(`%s /"%s/"`, queryString, term)
queryString = fmt.Sprintf(`%s %s`, queryString, term)
}
params.Set("query", queryString)
out := new(TicketSearchResults)
Expand Down
17 changes: 16 additions & 1 deletion zendesk/ticket.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package zendesk

import (
"fmt"
"github.com/google/go-querystring/query"
"strconv"
"strings"
"time"

"github.com/google/go-querystring/query"
)

// Ticket represents a Zendesk Ticket.
Expand Down Expand Up @@ -73,6 +74,20 @@ func (c *client) ShowTicket(id int64) (*Ticket, error) {
return out.Ticket, err
}

// ShowManyTickets accepts a comma-separated list of ticket ids or external ids.
//
// Zendesk Core API docs: https://developer.zendesk.com/rest_api/docs/support/tickets#show-multiple-tickets
func (c *client) ShowManyTickets(ids []int64) ([]Ticket, error) {
var sids []string
for _, id := range ids {
sids = append(sids, strconv.FormatInt(id, 10))
}

out := new(APIPayload)
err := c.get(fmt.Sprintf("/api/v2/tickets/show_many.json?ids=%s", strings.Join(sids, ",")), out)
return out.Tickets, err
}

func (c *client) CreateTicket(ticket *Ticket) (*Ticket, error) {
in := &APIPayload{Ticket: ticket}
out := new(APIPayload)
Expand Down
1 change: 1 addition & 0 deletions zendesk/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func (c *client) ShowManyUsers(ids []int64) ([]User, error) {
err := c.get(fmt.Sprintf("/api/v2/users/show_many.json?ids=%s", strings.Join(sids, ",")), out)
return out.Users, err
}

// ShowManyUsersByExternalIDs accepts a comma-separated list of external ids.
//
// Zendesk Core API docs: https://developer.zendesk.com/rest_api/docs/support/users#show-many-users
Expand Down
2 changes: 2 additions & 0 deletions zendesk/zendesk.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type Client interface {
ListIdentities(int64) ([]UserIdentity, error)
ListLocales() ([]Locale, error)
ListOrganizationMembershipsByUserID(id int64) ([]OrganizationMembership, error)
ListOrganizationMembershipsByOrganisationID(id int64) ([]OrganizationMembership, error)
ListOrganizations(*ListOptions) ([]Organization, error)
ListOrganizationUsers(int64, *ListUsersOptions) ([]User, error)
ListOrganizationTickets(int64, *ListOptions, ...SideLoad) (*ListResponse, error)
Expand Down Expand Up @@ -70,6 +71,7 @@ type Client interface {
ShowLocale(int64) (*Locale, error)
ShowLocaleByCode(string) (*Locale, error)
ShowManyOrganizations([]int64) ([]Organization, error)
ShowManyTickets([]int64) ([]Ticket, error)
ShowManyUsers([]int64) ([]User, error)
ShowManyUsersByExternalIDs([]string) ([]User, error)
ShowOrganization(int64) (*Organization, error)
Expand Down