-
Notifications
You must be signed in to change notification settings - Fork 151
/
Copy pathnotification-request.js
183 lines (174 loc) · 5.56 KB
/
notification-request.js
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/* @flow */
type RequestMetadataType = {
id?: string,
userId?: string
}
export type EmailRequestType = RequestMetadataType & {
from: string,
to: string,
subject: string,
cc?: string[],
bcc?: string[],
replyTo?: string,
text?: string,
html?: string,
attachments?: {
contentType: string, // text/plain...
filename: string,
content: string | Buffer
// path?: string,
// href?: string,
// contentDisposition?: string,
// contentTransferEncoding?: string,
// cid?: string,
// raw?: string,
// encoding?: string,
// headers?: {[string]: string | number | boolean}
}[],
headers?: {[string]: string | number | boolean},
customize?: (string, EmailRequestType) => Promise<EmailRequestType>
}
export type PushRequestType = RequestMetadataType & {
registrationToken: string,
title: string,
body: string,
custom?: Object,
priority?: 'high' | 'normal', // gcm, apn. Will be translated to 10 and 5 for apn. Defaults to 'high'
collapseKey?: string, // gcm for android, used as collapseId in apn
contentAvailable?: boolean, // gcm for android
delayWhileIdle?: boolean, // gcm for android
restrictedPackageName?: string, // gcm for android
dryRun?: boolean, // gcm for android
icon?: string, // gcm for android
tag?: string, // gcm for android
color?: string, // gcm for android
clickAction?: string, // gcm for android. In ios, category will be used if not supplied
locKey?: string, // gcm, apn
bodyLocArgs?: string, // gcm, apn
titleLocKey?: string, // gcm, apn
titleLocArgs?: string, // gcm, apn
retries?: number, // gcm, apn
encoding?: string, // apn
badge?: number, // gcm for ios, apn
sound?: string, // gcm, apn
alert?: string | Object, // apn, will take precedence over title and body
titleLocKey?: string, // apn and gcm for ios
titleLocArgs?: string, // apn and gcm for ios
launchImage?: string, // apn and gcm for ios
action?: string, // apn and gcm for ios
topic?: string, // apn and gcm for ios
category?: string, // apn and gcm for ios
contentAvailable?: string, // apn and gcm for ios
mdm?: string, // apn and gcm for ios
urlArgs?: string, // apn and gcm for ios
truncateAtWordEnd?: boolean, // apn and gcm for ios
mutableContent?: number, // apn
expiry?: number, // seconds
timeToLive?: number, // if both expiry and timeToLive are given, expiry will take precedency
headers?: {[string]: string | number | boolean}, // wns
launch?: string, // wns
duration?: string, // wns
consolidationKey?: string, // ADM
customize?: (string, PushRequestType) => Promise<PushRequestType>
}
export type SmsRequestType = RequestMetadataType & {
from: string,
to: string,
text: string,
type?: 'text' | 'unicode', // Defaults to 'text'
nature?: 'marketing' | 'transactional',
ttl?: number,
messageClass?: 0 | 1 | 2 | 3, // 0 for Flash SMS, 1 - ME-specific, 2 - SIM / USIM specific, 3 - TE-specific
// } & (
// {type?: 'text', text: string}
// | {type: 'unicode', text: string}
// | {type: 'binary', body: string, udh: string, protocolId: string}
// | {type: 'wappush', title: string, url: string, validity?: number}
// | {type: 'vcal', vcal: string}
// | {type: 'vcard', vcard: string}
// )
customize?: (string, SmsRequestType) => Promise<SmsRequestType>
}
export type VoiceRequestType = RequestMetadataType & {
from: string,
to: string,
url: string,
method?: string,
fallbackUrl?: string,
fallbackMethod?: string,
statusCallback?: string,
statusCallbackEvent?: string[],
sendDigits?: string,
machineDetection?: string,
machineDetectionTimeout?: number,
timeout?: number,
customize?: (string, VoiceRequestType) => Promise<VoiceRequestType>
}
export type WebpushRequestType = RequestMetadataType & {
subscription: {
endpoint: string,
keys: {
auth: string,
p256dh: string
}
},
title: string, // C22 F22 S6
body: string, // C22 F22 S6
actions?: {
action: string,
title: string,
icon?: string
}[], // C53
badge?: string, // C53
dir?: 'auto' | 'rtl' | 'ltr', // C22 F22 S6
icon?: string, // C22 F22
image?: string, // C55 F22
redirects?: {[key: string]: string}, // added for local tests
requireInteraction?: boolean, // C22 F52
customize?: (string, WebpushRequestType) => Promise<WebpushRequestType>
}
export type SlackRequestType = RequestMetadataType & {
webhookUrl?: string, // Required if not configured in provider
text: string,
unfurl_links?: boolean,
attachments?: {
fallback?: string,
color?: string,
pretext?: string,
author_name?: string,
author_link?: string,
author_icon?: string,
title?: string,
title_link?: string,
text?: string,
fields?: {
title?: string,
value?: string,
short?: boolean
}[],
actions?: {
type: 'button',
text: string,
url: string,
style?: 'primary' | 'danger'
}[],
image_url?: string,
thumb_url?: string,
footer?: string,
footer_icon?: string,
ts?: number
}[],
customize?: (string, SlackRequestType) => Promise<SlackRequestType>
}
export type WhatsappRequestType = RequestMetadataType & {
from: string,
to: string,
type: 'template' | 'text' | 'document' | 'image' | 'audio' | 'video' | 'sticker', // | 'location' | 'contact',
text?: string,
mediaUrl?: string,
templateName?: string,
templateData?: Object,
messageId?: string,
customize?: (string, WhatsappRequestType) => Promise<WhatsappRequestType>
}
export type RequestType = EmailRequestType | PushRequestType | SmsRequestType | VoiceRequestType | WebpushRequestType | SlackRequestType | WhatsappRequestType