-
Notifications
You must be signed in to change notification settings - Fork 72
/
notification.go
60 lines (52 loc) · 1.91 KB
/
notification.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package trello
import (
"time"
)
// Notification represents a Trello Notification.
// https://developers.trello.com/reference/#notifications
type Notification struct {
client *Client
ID string `json:"id"`
IDAction string `json:"idAction"`
Unread bool `json:"unread"`
Type string `json:"type"`
IDMemberCreator string `json:"idMemberCreator"`
Date time.Time `json:"date"`
DateRead time.Time `json:"dataRead"`
Data NotificationData `json:"data,omitempty"`
MemberCreator *Member `json:"memberCreator,omitempty"`
}
// NotificationData represents the 'notificaiton.data'
type NotificationData struct {
Text string `json:"text"`
Card *NotificationDataCard `json:"card,omitempty"`
Board *NotificationDataBoard `json:"board,omitempty"`
}
// NotificationDataBoard represents the 'notification.data.board'
type NotificationDataBoard struct {
ID string `json:"id"`
ShortLink string `json:"shortLink"`
Name string `json:"name"`
}
// NotificationDataCard represents the 'notification.data.card'
type NotificationDataCard struct {
ID string `json:"id"`
IDShort int `json:"idShort"`
Name string `json:"name"`
ShortLink string `json:"shortLink"`
}
// GetMyNotifications returns the notifications of the authenticated user
func (c *Client) GetMyNotifications(extraArgs ...Arguments) (notifications []*Notification, err error) {
args := flattenArguments(extraArgs)
path := "members/me/notifications"
err = c.Get(path, args, ¬ifications)
for i := range notifications {
notifications[i].SetClient(c)
}
return
}
// SetClient can be used to override this Notification's internal connection to
// the Trello API. Normally, this is set automatically after API calls.
func (n *Notification) SetClient(newClient *Client) {
n.client = newClient
}