Skip to content

Commit

Permalink
add show group (#111)
Browse files Browse the repository at this point in the history
* add show group

* missed interface
  • Loading branch information
vgw-chriskruger authored Jun 7, 2024
1 parent 6db2fe8 commit 2c8fcdc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions zendesk/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ type Group struct {
UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

// ShowGroup fetches a group by its ID.
//
// Zendesk Core API docs: https://developer.zendesk.com/rest_api/docs/core/groups#show-group
func (c *client) ShowGroup(id int64) (*Group, error) {
out := new(APIPayload)
err := c.get(fmt.Sprintf("/api/v2/groups/%d.json", id), out)
return out.Group, err
}

// CreateGroup creates a group.
func (c *client) CreateGroup(group *Group) (*Group, error) {
in := &APIPayload{Group: group}
Expand Down
7 changes: 7 additions & 0 deletions zendesk/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ func TestGroupCRUD(t *testing.T) {
require.NotNil(t, created.CreatedAt)
require.NotNil(t, created.UpdatedAt)

showed, err := client.ShowGroup(*created.ID)
require.NoError(t, err)
require.NotNil(t, showed.ID)
require.NotNil(t, showed.URL)
require.NotNil(t, showed.CreatedAt)
require.NotNil(t, showed.UpdatedAt)

afterCreateAllGroups, err := client.ListGroups()
require.NoError(t, err)
require.True(t, len(afterCreateAllGroups) > len(beforeCreateAllGroups))
Expand Down
1 change: 1 addition & 0 deletions zendesk/zendesk.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type Client interface {
ShowOrganization(int64) (*Organization, error)
ShowTicket(int64) (*Ticket, error)
ShowUser(int64) (*User, error)
ShowGroup(int64) (*Group, error)
UpdateIdentity(int64, int64, *UserIdentity) (*UserIdentity, error)
UpdateOrganization(int64, *Organization) (*Organization, error)
UpdateTicket(int64, *Ticket) (*Ticket, error)
Expand Down

0 comments on commit 2c8fcdc

Please sign in to comment.