Skip to content

Commit

Permalink
List a user's contact methods
Browse files Browse the repository at this point in the history
Add the ability to list a user's contact methods
  • Loading branch information
facundoagriel committed Oct 23, 2017
1 parent 078a328 commit c54e2a4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions user.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ type GetUserOptions struct {
Includes []string `url:"include,omitempty,brackets"`
}

// ListUserContactMethodsResponse is the data structure returned from calling the ListUserContactMethods API endpoint.
type ListUserContactMethodsResponse struct {
APIListObject
ContactMethods []ContactMethod `json:"contact_methods"`
}

// ListUsers lists users of your PagerDuty account, optionally filtered by a search query.
func (c *Client) ListUsers(o ListUsersOptions) (*ListUsersResponse, error) {
v, err := query.Values(o)
Expand Down Expand Up @@ -122,3 +128,14 @@ func getUserFromResponse(c *Client, resp *http.Response, err error) (*User, erro
}
return &t, nil
}

// List a user's contact methods
func (c *Client) ListUserContactMethods(id string) (*ListUserContactMethodsResponse, error) {
resp, err := c.get("/users/" + id + "/contact_methods")
if err != nil {
return nil, err
}
var result ListUserContactMethodsResponse
return &result, c.decodeJSON(resp, &result)
}

0 comments on commit c54e2a4

Please sign in to comment.