add GetNotificationsExclude

This commit is contained in:
Rasmus Lindroth 2022-12-30 11:18:51 +01:00
parent ad3aa348dd
commit fe547bf14f
2 changed files with 27 additions and 2 deletions

View file

@ -37,8 +37,19 @@ type PushAlerts struct {
// GetNotifications returns notifications.
func (c *Client) GetNotifications(ctx context.Context, pg *Pagination) ([]*Notification, error) {
return c.GetNotificationsExclude(ctx, nil, pg)
}
// GetNotificationsExclude returns notifications with excluded notifications
func (c *Client) GetNotificationsExclude(ctx context.Context, exclude *[]string, pg *Pagination) ([]*Notification, error) {
var notifications []*Notification
err := c.doAPI(ctx, http.MethodGet, "/api/v1/notifications", nil, &notifications, pg)
params := url.Values{}
if exclude != nil {
for _, ex := range *exclude {
params.Add("exclude_types[]", ex)
}
}
err := c.doAPI(ctx, http.MethodGet, "/api/v1/notifications", params, &notifications, pg)
if err != nil {
return nil, err
}