-
Notifications
You must be signed in to change notification settings - Fork 10
/
payload.go
79 lines (70 loc) · 2.08 KB
/
payload.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package jpush
import (
"encoding/json"
)
type Payload struct {
Platform *Platform `json:"platform"`
Audience *Audience `json:"audience"`
Notification *Notification `json:"notification,omitempty"`
Message *Message `json:"message,omitempty"`
SmsMessage *SmsMessage `json:"sms_message,omitempty"`
Options *Options `json:"options,omitempty"`
Cid string `json:"cid,omitempty"`
}
func (p *Payload) MarshalJSON() ([]byte, error) {
payload := struct {
Platform interface{} `json:"platform"`
Audience interface{} `json:"audience"`
Notification *Notification `json:"notification,omitempty"`
Message *Message `json:"message,omitempty"`
SmsMessage *SmsMessage `json:"sms_message,omitempty"`
Options *Options `json:"options,omitempty"`
Cid string `json:"cid,omitempty"`
}{
Platform: p.Platform.Interface(),
Audience: p.Audience.Interface(),
Notification: p.Notification,
Message: p.Message,
SmsMessage: p.SmsMessage,
Options: p.Options,
Cid: p.Cid,
}
return json.Marshal(payload)
}
type Single struct {
Time string `json:"time"`
}
const (
Day = "day"
Week = "week"
Month = "month"
)
const (
WeekMonday = "MON"
WeekTuesday = "TUE"
WeekWednesday = "WED"
WeekThursday = "THU"
WeekFriday = "FRI"
WeekSaturday = "SAT"
WeekSunday = "SUN"
)
type Periodical struct {
Start string `json:"start"`
End string `json:"end"`
Time string `json:"time"`
TimeUnit string `json:"time_unit"`
Frequency int `json:"frequency"`
Point []string `json:"point,omitempty"`
}
type Trigger struct {
Single *Single `json:"single,omitempty"`
Periodical *Periodical `json:"periodical,omitempty"`
}
type SchedulePayload struct {
ScheduleId string `json:"schedule_id,omitempty"`
Name string `json:"name,omitempty"`
Enabled bool `json:"enabled,omitempty"`
Trigger *Trigger `json:"trigger,omitempty"`
Push *Payload `json:"push,omitempty"`
Cid string `json:"cid,omitempty"`
}