Add /api/v1/notifications/dismiss
This commit is contained in:
parent
c09198f7c9
commit
8f6192e26b
|
@ -107,6 +107,7 @@ func main() {
|
||||||
* [x] GET /api/v1/mutes
|
* [x] GET /api/v1/mutes
|
||||||
* [x] GET /api/v1/notifications
|
* [x] GET /api/v1/notifications
|
||||||
* [x] GET /api/v1/notifications/:id
|
* [x] GET /api/v1/notifications/:id
|
||||||
|
* [x] POST /api/v1/notifications/dismiss
|
||||||
* [x] POST /api/v1/notifications/clear
|
* [x] POST /api/v1/notifications/clear
|
||||||
* [x] GET /api/v1/reports
|
* [x] GET /api/v1/reports
|
||||||
* [x] POST /api/v1/reports
|
* [x] POST /api/v1/reports
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -36,6 +37,17 @@ func (c *Client) GetNotification(ctx context.Context, id ID) (*Notification, err
|
||||||
return ¬ification, nil
|
return ¬ification, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DismissNotification deletes a single notification.
|
||||||
|
func (c *Client) DismissNotification(ctx context.Context, id ID) error {
|
||||||
|
params := url.Values{}
|
||||||
|
params.Add("id", string(id))
|
||||||
|
err := c.doAPI(ctx, http.MethodPost, "/api/v1/notifications/dismiss", params, nil, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// ClearNotifications clear notifications.
|
// ClearNotifications clear notifications.
|
||||||
func (c *Client) ClearNotifications(ctx context.Context) error {
|
func (c *Client) ClearNotifications(ctx context.Context) error {
|
||||||
return c.doAPI(ctx, http.MethodPost, "/api/v1/notifications/clear", nil, nil, nil)
|
return c.doAPI(ctx, http.MethodPost, "/api/v1/notifications/clear", nil, nil, nil)
|
||||||
|
|
|
@ -20,6 +20,9 @@ func TestGetNotifications(t *testing.T) {
|
||||||
case "/api/v1/notifications/clear":
|
case "/api/v1/notifications/clear":
|
||||||
fmt.Fprintln(w, `{}`)
|
fmt.Fprintln(w, `{}`)
|
||||||
return
|
return
|
||||||
|
case "/api/v1/notifications/dismiss":
|
||||||
|
fmt.Fprintln(w, `{}`)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
||||||
return
|
return
|
||||||
|
@ -56,4 +59,8 @@ func TestGetNotifications(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should not be fail: %v", err)
|
t.Fatalf("should not be fail: %v", err)
|
||||||
}
|
}
|
||||||
|
err = client.DismissNotification(context.Background(), "123")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("should not be fail: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user