forked from googlearchive/go-gcm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
requests.go
69 lines (58 loc) · 2.25 KB
/
requests.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
package googlemessaging
import (
"errors"
)
var (
ErrInvalidToken = errors.New("invalid token")
ErrDeviceNotFound = errors.New("device not found")
ErrInvalidRequest = errors.New("invalid request")
ErrInalidFCMServiceAccountFile = errors.New("invalid fcm service account file")
)
type FcmMessageBody struct {
Message *FcmHttpMessage `json:"message"`
}
type FcmHttpMessage struct {
Token string `json:"token,omitempty"`
Notification *FcmNotification `json:"notification,omitempty"`
Data FcmData `json:"data,omitempty"`
Android *FcmAndroidConfig `json:"android"`
}
type FcmNotification struct {
Title string `json:"title"`
Body string `json:"body"`
Image string `json:"image"`
}
type FcmAndroidConfig struct {
CollapseKey string `json:"collapse_key"`
Priority string `json:"priority,omitempty"`
TimeToLive *string `json:"ttl,omitempty"`
RestrictedPackageName string `json:"restricted_package_name,omitempty"`
Notification *FcmAndroidNotification `json:"notification"`
}
type FcmAndroidNotification struct {
Icon string `json:"icon,omitempty"`
Color string `json:"color,omitempty"`
Sound string `json:"sound,omitempty"`
Tag string `json:"tag,omitempty"`
ClickAction string `json:"click_action,omitempty"`
BodyLocKey string `json:"body_loc_key,omitempty"`
BodyLocArgs []string `json:"body_loc_args,omitempty"`
TitleLocKey string `json:"title_loc_key,omitempty"`
TitleLocArgs []string `json:"title_loc_args,omitempty"`
Ticker string `json:"ticker,omitempty"`
Sticky bool `json:"sticky,omitempty"`
LocalOnly bool `json:"local_only,omitempty"`
NotificationCount int `json:"notification_count,omitempty"`
ChannelId string `json:"channel_id,omitempty"`
}
type FcmData map[string]string
type FcmSendHttpResponse struct {
Status int `json:"-"`
Name string `json:"name"`
}
type InstanceInformationResponse struct {
AuthorizedEntity string `json:"authorizedEntity"`
}
type ErrorResponse struct {
Error string `json:"error"`
}