Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to list a user's contact methods #97

Merged
merged 1 commit into from
Aug 13, 2019
Merged
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
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)
}