diff options
Diffstat (limited to 'vendor/github.com/slack-go/slack/reminders.go')
-rw-r--r-- | vendor/github.com/slack-go/slack/reminders.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/vendor/github.com/slack-go/slack/reminders.go b/vendor/github.com/slack-go/slack/reminders.go index 9b905387..de1170a6 100644 --- a/vendor/github.com/slack-go/slack/reminders.go +++ b/vendor/github.com/slack-go/slack/reminders.go @@ -21,6 +21,11 @@ type reminderResp struct { Reminder Reminder `json:"reminder"` } +type remindersResp struct { + SlackResponse + Reminders []Reminder `json:"reminders"` +} + func (api *Client) doReminder(ctx context.Context, path string, values url.Values) (*Reminder, error) { response := &reminderResp{} if err := api.postMethod(ctx, path, values, response); err != nil { @@ -29,6 +34,31 @@ func (api *Client) doReminder(ctx context.Context, path string, values url.Value return &response.Reminder, response.Err() } +func (api *Client) doReminders(ctx context.Context, path string, values url.Values) ([]*Reminder, error) { + response := &remindersResp{} + if err := api.postMethod(ctx, path, values, response); err != nil { + return nil, err + } + + // create an array of pointers to reminders + var reminders = make([]*Reminder, 0, len(response.Reminders)) + for _, reminder := range response.Reminders { + reminders = append(reminders, &reminder) + } + + return reminders, response.Err() +} + +// ListReminders lists all the reminders created by or for the authenticated user +// +// See https://api.slack.com/methods/reminders.list +func (api *Client) ListReminders() ([]*Reminder, error) { + values := url.Values{ + "token": {api.token}, + } + return api.doReminders(context.Background(), "reminders.list", values) +} + // AddChannelReminder adds a reminder for a channel. // // See https://api.slack.com/methods/reminders.add (NOTE: the ability to set |