Add Pagination
This commit is contained in:
parent
759ce4a331
commit
d32c4d4ed1
12 changed files with 217 additions and 254 deletions
|
@ -17,19 +17,19 @@ type Notification struct {
|
|||
}
|
||||
|
||||
// GetNotifications return notifications.
|
||||
func (c *Client) GetNotifications(ctx context.Context) ([]*Notification, error) {
|
||||
func (c *Client) GetNotifications(ctx context.Context, pg *Pagination) ([]*Notification, *Pagination, error) {
|
||||
var notifications []*Notification
|
||||
err := c.doAPI(ctx, http.MethodGet, "/api/v1/notifications", nil, ¬ifications, nil)
|
||||
retPG, err := c.doAPI(ctx, http.MethodGet, "/api/v1/notifications", nil, ¬ifications, pg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
return notifications, nil
|
||||
return notifications, retPG, nil
|
||||
}
|
||||
|
||||
// GetNotification return notification.
|
||||
func (c *Client) GetNotification(ctx context.Context, id int64) (*Notification, error) {
|
||||
var notification Notification
|
||||
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/notifications/%d", id), nil, ¬ification, nil)
|
||||
_, err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/notifications/%d", id), nil, ¬ification, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -38,5 +38,6 @@ func (c *Client) GetNotification(ctx context.Context, id int64) (*Notification,
|
|||
|
||||
// ClearNotifications clear notifications.
|
||||
func (c *Client) ClearNotifications(ctx context.Context) error {
|
||||
return c.doAPI(ctx, http.MethodPost, "/api/v1/notifications/clear", nil, nil, nil)
|
||||
_, err := c.doAPI(ctx, http.MethodPost, "/api/v1/notifications/clear", nil, nil, nil)
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue