aboutsummaryrefslogtreecommitdiff
path: root/mastodon/notification.go
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2019-12-13 18:08:26 +0000
committerr <r@freesoftwareextremist.com>2019-12-13 18:26:24 +0000
commit5e4da01c3ae3ae2e870faba9085d9d9213c01c29 (patch)
tree39d6f1e76b901549f194ddbac3c6cb82e0abd019 /mastodon/notification.go
downloadbloat-5e4da01c3ae3ae2e870faba9085d9d9213c01c29.tar.gz
bloat-5e4da01c3ae3ae2e870faba9085d9d9213c01c29.zip
Initial commit
Diffstat (limited to 'mastodon/notification.go')
-rw-r--r--mastodon/notification.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/mastodon/notification.go b/mastodon/notification.go
new file mode 100644
index 0000000..236fcbf
--- /dev/null
+++ b/mastodon/notification.go
@@ -0,0 +1,42 @@
+package mastodon
+
+import (
+ "context"
+ "fmt"
+ "net/http"
+ "time"
+)
+
+// Notification hold information for mastodon notification.
+type Notification struct {
+ ID string `json:"id"`
+ Type string `json:"type"`
+ CreatedAt time.Time `json:"created_at"`
+ Account Account `json:"account"`
+ Status *Status `json:"status"`
+}
+
+// GetNotifications return notifications.
+func (c *Client) GetNotifications(ctx context.Context, pg *Pagination) ([]*Notification, error) {
+ var notifications []*Notification
+ err := c.doAPI(ctx, http.MethodGet, "/api/v1/notifications", nil, &notifications, pg)
+ if err != nil {
+ return nil, err
+ }
+ return notifications, nil
+}
+
+// GetNotification return notification.
+func (c *Client) GetNotification(ctx context.Context, id string) (*Notification, error) {
+ var notification Notification
+ err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/notifications/%v", id), nil, &notification, nil)
+ if err != nil {
+ return nil, err
+ }
+ return &notification, nil
+}
+
+// ClearNotifications clear notifications.
+func (c *Client) ClearNotifications(ctx context.Context) error {
+ return c.doAPI(ctx, http.MethodPost, "/api/v1/notifications/clear", nil, nil, nil)
+}