-
Notifications
You must be signed in to change notification settings - Fork 24
/
preferences.go
39 lines (33 loc) · 1.09 KB
/
preferences.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
package support
type Preference struct {
ClientID string
NotificationID string
Count int
Email bool
NotificationDescription string
SourceDescription string
}
type Preferences struct {
GlobalUnsubscribe bool
NotificationPreferences []Preference
}
type ClientPreferences map[string]NotificationPreference
func (response PreferenceDocument) Preferences() Preferences {
var preferences []Preference
for clientID, clientPreferences := range response.Clients {
for notificationID, notificationPreference := range clientPreferences {
preferences = append(preferences, Preference{
ClientID: clientID,
NotificationID: notificationID,
Count: notificationPreference.Count,
Email: notificationPreference.Email,
NotificationDescription: notificationPreference.NotificationDescription,
SourceDescription: notificationPreference.SourceDescription,
})
}
}
return Preferences{
GlobalUnsubscribe: response.GlobalUnsubscribe,
NotificationPreferences: preferences,
}
}