Rework the API wrappers to handle arrays of parameters
This make some API calls work better (reports with several statuses,
statuses with several attachments, relationships for multiple
accounts...).
package gondole
import (
"strconv"
"github.com/sendgrid/rest"
)
// GetNotifications returns the list of the user's notifications
func (g *Client) GetNotifications() ([]Notification, error) {
var notifications []Notification
if err := g.apiCall("notifications", rest.Get, nil, ¬ifications); err != nil {
return nil, err
}
return notifications, nil
}
// GetNotification returns a notification
// The returned notification can be nil if there is an error or if the
// requested notification does not exist.
func (g *Client) GetNotification(id int) (*Notification, error) {
if id < 1 {
return nil, ErrInvalidID
}
var endPoint = "notifications/" + strconv.Itoa(id)
var notification Notification
if err := g.apiCall(endPoint, rest.Get, nil, ¬ification); err != nil {
return nil, err
}
if notification.ID == 0 {
return nil, ErrEntityNotFound
}
return ¬ification, nil
}
// ClearNotifications deletes all notifications from the Mastodon server for
// the authenticated user
func (g *Client) ClearNotifications() error {
return g.apiCall("notifications/clear", rest.Post, nil, &Notification{})
}