-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpush.go
More file actions
39 lines (31 loc) · 806 Bytes
/
push.go
File metadata and controls
39 lines (31 loc) · 806 Bytes
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 push
import "fmt"
type Pusher interface {
Setup() error
AddToken(token Token) error
GetTokens() []Token
ResetTokens() error
Send(notification Notification) (SendResponse, error)
}
type PushManagerByPlatform map[Platform]Pusher
type Notification struct {
UUIDs []string `json:"uuids"`
Title string `json:"title"`
Text string `json:"text"`
Custom map[string]interface{} `json:"custom"`
}
type SendResponse struct {
InvalidTokens []Token
}
func (n Notification) Validate() error {
if len(n.UUIDs) == 0 {
return fmt.Errorf("'uuids' is required and must contains at least 1 UUID")
}
if n.Text == "" {
return fmt.Errorf("'text' is required")
}
return nil
}
type SendService interface {
Send(notification Notification) error
}