From 8c434b52828c0995528401a470fb9d309aaf9504 Mon Sep 17 00:00:00 2001 From: Hanage999 Date: Mon, 3 May 2021 10:16:04 +0900 Subject: [PATCH] Replace deprecated /api/v1/notifications/dismiss with new API --- README.md | 2 +- notification.go | 8 +------- notification_test.go | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 21af6af..07ab506 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ func main() { * [x] GET /api/v1/mutes * [x] GET /api/v1/notifications * [x] GET /api/v1/notifications/:id -* [x] POST /api/v1/notifications/dismiss +* [x] POST /api/v1/notifications/:id/dismiss * [x] POST /api/v1/notifications/clear * [x] POST /api/v1/push/subscription * [x] GET /api/v1/push/subscription diff --git a/notification.go b/notification.go index 66f8e30..b24b9df 100644 --- a/notification.go +++ b/notification.go @@ -57,13 +57,7 @@ func (c *Client) GetNotification(ctx context.Context, id ID) (*Notification, err // 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 + return c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/notifications/%v/dismiss", id), nil, nil, nil) } // ClearNotifications clear notifications. diff --git a/notification_test.go b/notification_test.go index 124a0d7..28dc975 100644 --- a/notification_test.go +++ b/notification_test.go @@ -23,7 +23,7 @@ func TestGetNotifications(t *testing.T) { case "/api/v1/notifications/clear": fmt.Fprintln(w, `{}`) return - case "/api/v1/notifications/dismiss": + case "/api/v1/notifications/123/dismiss": fmt.Fprintln(w, `{}`) return }