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

Update on_call.go to accept a context.Context #287

Merged
merged 1 commit into from
Mar 10, 2021
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
18 changes: 15 additions & 3 deletions on_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,28 @@ type ListOnCallOptions struct {
Earliest bool `url:"earliest,omitempty"`
}

// ListOnCalls list the on-call entries during a given time range.
// ListOnCalls list the on-call entries during a given time range. It's
// recommended to use ListOnCallsWithContext instead.
func (c *Client) ListOnCalls(o ListOnCallOptions) (*ListOnCallsResponse, error) {
return c.ListOnCallsWithContext(context.Background(), o)
}

// ListOnCallsWithContext list the on-call entries during a given time range.
func (c *Client) ListOnCallsWithContext(ctx context.Context, o ListOnCallOptions) (*ListOnCallsResponse, error) {
v, err := query.Values(o)
if err != nil {
return nil, err
}
resp, err := c.get(context.TODO(), "/oncalls?"+v.Encode())

resp, err := c.get(ctx, "/oncalls?"+v.Encode())
if err != nil {
return nil, err
}

var result ListOnCallsResponse
return &result, c.decodeJSON(resp, &result)
if err := c.decodeJSON(resp, &result); err != nil {
return nil, err
}

return &result, nil
}