breaking compatibility changes. take context for first arguments.
This commit is contained in:
parent
32e66a3d72
commit
5e84b57bf3
18 changed files with 176 additions and 139 deletions
|
@ -1,6 +1,7 @@
|
|||
package mastodon
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
@ -16,9 +17,9 @@ type Notification struct {
|
|||
}
|
||||
|
||||
// GetNotifications return notifications.
|
||||
func (c *Client) GetNotifications() ([]*Notification, error) {
|
||||
func (c *Client) GetNotifications(ctx context.Context) ([]*Notification, error) {
|
||||
var notifications []*Notification
|
||||
err := c.doAPI(http.MethodGet, "/api/v1/notifications", nil, ¬ifications)
|
||||
err := c.doAPI(ctx, http.MethodGet, "/api/v1/notifications", nil, ¬ifications)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -26,9 +27,9 @@ func (c *Client) GetNotifications() ([]*Notification, error) {
|
|||
}
|
||||
|
||||
// GetNotification return notifications.
|
||||
func (c *Client) GetNotification(id int64) (*Notification, error) {
|
||||
func (c *Client) GetNotification(ctx context.Context, id int64) (*Notification, error) {
|
||||
var notification Notification
|
||||
err := c.doAPI(http.MethodGet, fmt.Sprintf("/api/v1/notifications/%d", id), nil, ¬ification)
|
||||
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/notifications/%d", id), nil, ¬ification)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -36,6 +37,6 @@ func (c *Client) GetNotification(id int64) (*Notification, error) {
|
|||
}
|
||||
|
||||
// ClearNotifications clear notifications.
|
||||
func (c *Client) ClearNotifications() error {
|
||||
return c.doAPI(http.MethodPost, "/api/v1/notifications/clear", nil, nil)
|
||||
func (c *Client) ClearNotifications(ctx context.Context) error {
|
||||
return c.doAPI(ctx, http.MethodPost, "/api/v1/notifications/clear", nil, nil)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue