-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.go
245 lines (231 loc) · 13.4 KB
/
model.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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
package onesignal
// Success model for success responses from OneSignal API
type Success struct {
ID string `json:"id,omitempty"`
Recipients int `json:"recipients,omitempty"`
ExternalID string `json:"external_id,omitempty"`
Success bool `json:"success,omitempty"`
Errors interface{} `json:"errors,omitempty"`
TotalCount int `json:"total_count,omitempty"` // Show on BrowseNotification
Offset int `json:"offset,omitempty"` // Show on BrowseNotification
Limit int `json:"limit,omitempty"` // Show on BrowseNotification
Notifications []interface{} `json:"notifications,omitempty"` // Show on BrowseNotification
}
// Errors model for all the error request
type Errors struct {
Errors []string `json:"errors,omitempty"`
}
// DeviceResponse model for response browse devices
type DeviceResponse struct {
TotalCount int `json:"total_count,omitempty"`
Offset int `json:"offset,omitempty"`
Limit int `json:"limit,omitempty"`
Players []interface{} `json:"players,omitempty"`
}
// SpecificDevice model for request who wants to send to the specific device
//
// For more information, you can read this parameter reference from
// OneSignal API Reference https://documentation.onesignal.com/reference/create-notification#send-to-specific-devices
type SpecificDevice struct {
// IncludedSegments, you can filled with ["Active Users", "Inactive Users", "Subscribed Users", "Unsubscribed Users"].
// Included segment required to send what you want to your target. Users in these segments will receive a notification
IncludedSegments []string `json:"included_segments,omitempty"`
// IncludePlayerIDS, you can filled with users device ID
// With this settings, you can send your notification to specific device
IncludePlayerIDS []string `json:"include_player_ids,omitempty"`
IncludeExternalUserIDS []string `json:"include_external_user_ids,omitempty"`
IncludeEmailTokens []string `json:"include_email_tokens,omitempty"`
IncludeIosTokens []string `json:"include_ios_tokens,omitempty"`
IncludeWpWnsUris []string `json:"include_wp_wns_uris,omitempty"`
IncludeAmazonRegIDS []string `json:"include_amazon_reg_ids,omitempty"`
IncludeChromeRegIDS []string `json:"include_chrome_reg_ids,omitempty"`
IncludeAndroidRegIDS []string `json:"include_android_reg_ids,omitempty"`
}
// NotificationContent model for request who send a push notifications
//
// For more information, you can read this parameter reference from
// OneSignal API Reference https://documentation.onesignal.com/reference/create-notification#content--language
type NotificationContent struct {
// Set your notification title with these, then you can set a different title for the specific language
Headings interface{} `json:"headings,omitempty"`
// Set your notification subtitle with these, then you can set a different subtitle for the specific language
Subtitle interface{} `json:"subtitle,omitempty"`
// If you already set up a template with your account, and want to use that template, filled with your template ID
TemplateID string `json:"template_id,omitempty"`
// These configs just for iOS to displaying a notification content
ContentAvailable bool `json:"content_available,omitempty"`
// Set your notification content with these, then you can set a different content for the specific language
Contents interface{} `json:"contents,omitempty"`
}
// EmailContent model for request who send an email
//
// For more information, you can read this parameter reference from
// OneSignal API Reference https://documentation.onesignal.com/reference/create-notification#email-content
type EmailContent struct {
// These config required for the subject of the email
EmailSubject string `json:"email_subject,omitempty"`
// These config required for the content of the email
EmailBody string `json:"email_body,omitempty"`
// The name the email is from. If this is not specified, this will use your default from name set in email set up
EmailFromName string `json:"email_from_name,omitempty"`
// The email address the email is from. If this is not specified, this will use your default from email in email set up
EmailFromAddress string `json:"email_fromaddress,omitempty"`
}
// Attachments model for additional content attached to push notifications, primarily images
//
// For more information, you can read this parameter reference from
// OneSignal API Reference https://documentation.onesignal.com/reference/create-notification#attachments
type Attachments struct {
// A custom map of data that is passed back to your app.
Data interface{} `json:"data,omitempty"`
// The URL to open in the browser when a user clicks on the notification.
URL string `json:"url,omitempty"`
// Same as URL but only sent to web push platforms.
// Including Chrome, Firefox, Safari, Opera, etc.
WebURL string `json:"web_url,omitempty"`
// Same as URL but only sent to app platforms.
// Including iOS, Android, macOS, Windows, ChromeApps, etc.
AppURL string `json:"app_url,omitempty"`
// Adds media attachments to notifications. Set as JSON object, key as a media id of your choice and the value as a valid local filename or URL.
// User must press and hold on the notification to view.
IosAttachments interface{} `json:"ios_attachments,omitempty"`
// Picture to display in the expanded view. Can be a drawable resource name or a URL.
BigPicture string `json:"big_picture,omitempty"`
// Sets the web push notification's large image to be shown below the notification's title and text. Please see Web Push Notification Icons.
ChromeWebImage string `json:"chrome_web_image,omitempty"`
// Picture to display in the expanded view. Can be a drawable resource name or a URL.
// Only used for Amazon platform
AdmBigPicture string `json:"adm_big_picture,omitempty"`
// Picture to display in the expanded view. Can be a drawable resource name or a URL.
// Only used for ChromeApp platform
ChromeBigPicture string `json:"chrome_big_picture,omitempty"`
}
// ActionButtons model for added buttons to push notifications
//
// For more information, you can read this parameter reference from
// OneSignal API Reference https://documentation.onesignal.com/reference/create-notification#action-buttons
type ActionButtons struct {
// Buttons to add to the notification. Icon only works for Android.
Buttons []interface{} `json:"buttons,omitempty"`
// Add action buttons to the notification. The id field is required.
WebButtons []interface{} `json:"web_buttons,omitempty"`
// Category APS payload, use with registerUserNotificationSettings:categories in your Objective-C / Swift code.
IosCategory string `json:"ios_category,omitempty"`
}
// Appearance model for adjust icons, badges, and other appearance changes to your push notifications
//
// For more information, you can read this parameter reference from
// OneSignal API Reference https://documentation.onesignal.com/reference/create-notification#appearance
type Appearance struct {
AndroidChannelID string `json:"android_channel_id,omitempty"`
HuaweiChannelID string `json:"huawei_channel_id,omitempty"`
ExistingAndroidChannelID string `json:"existing_android_channel_id,omitempty"`
HuaweiExistingChannelID string `json:"huawei_existing_channel_id,omitempty"`
AndroidBackgroundLayout interface{} `json:"android_background_layout,omitempty"`
SmallIcon string `json:"small_icon,omitempty"`
HuaweiSmallIcon string `json:"huawei_small_icon,omitempty"`
LargeIcon string `json:"large_icon,omitempty"`
HuaweiLargeIcon string `json:"huawei_large_icon,omitempty"`
AdmSmallIcon string `json:"adm_small_icon,omitempty"`
AdmLargeIcon string `json:"adm_large_icon,omitempty"`
ChromeWebIcon string `json:"chrome_web_icon,omitempty"`
ChromeWebBadge string `json:"chrome_web_badge,omitempty"`
FirefoxIcon string `json:"firefox_icon,omitempty"`
ChromeIcon string `json:"chrome_icon,omitempty"`
IosSound string `json:"ios_sound,omitempty"`
AndroidSound string `json:"android_sound,omitempty"`
HuaweiSound string `json:"huawei_sound,omitempty"`
AdmSound string `json:"adm_sound,omitempty"`
WpWnsSound string `json:"WpWnsSound,omitempty"`
AndroidLedColor string `json:"android_led_color,omitempty"`
HuaweiLedColor string `json:"huawei_led_color,omitempty"`
AndroidAccentColor string `json:"android_accent_color,omitempty"`
HuaweiAccentColor string `json:"huawei_accent_color,omitempty"`
AndroidVisibility int `json:"android_visibility,omitempty"`
HuaweiVisibility int `json:"huawei_visibility,omitempty"`
IosBadgeType string `json:"ios_badgeType,omitempty"`
IosBadgeCount int `json:"ios_badgeCount,omitempty"`
CollapseID string `json:"collapse_id,omitempty"`
ApnsAlert interface{} `json:"apns_alert,omitempty"`
}
// Delivery model for set schedule notification for future delivery.
//
// For more information, you can read this parameter reference from
// OneSignal API Reference https://documentation.onesignal.com/reference/create-notification#delivery
type Delivery struct {
SendAfter string `json:"send_after,omitempty"`
DelayedOption string `json:"delayed_option,omitempty"`
DeliveryTimeOfDay string `json:"delivery_time_of_day,omitempty"`
TTL int `json:"ttl,omitempty"`
Priority int `json:"priority,omitempty"`
ApnsPushTypeOverride string `json:"apns_push_type_override,omitempty"`
}
// Grouping model for combine multiple notifications into a single notification to improve the user experience.
//
// For more information, you can read this parameter reference from
// OneSignal API Reference https://documentation.onesignal.com/reference/create-notification#grouping--collapsing
type Grouping struct {
AndroidGroup string `json:"android_group,omitempty"`
AndroidGroupMessage interface{} `json:"android_group_message,omitempty"`
AdmGroup string `json:"adm_group,omitempty"`
AdmGroupMessage interface{} `json:"adm_group_message,omitempty"`
ThreadID string `json:"thread_id,omitempty"`
SummaryArg string `json:"summary_arg,omitempty"`
SummaryArgCunt int `json:"summaryArgCount,omitempty"`
}
// Platform model for only send to specific platforms.
//
// For more information, you can read this parameter reference from
// OneSignal API Reference https://documentation.onesignal.com/reference/create-notification#platform-to-deliver-to
type Platform struct {
IsIos bool `json:"isIos,omitempty"`
IsAndroid bool `json:"isAndroid,omitempty"`
IsHuawei bool `json:"isHuawei,omitempty"`
IsAnyWeb bool `json:"isAnyWeb,omitempty"`
IsEmail bool `json:"isEmail,omitempty"`
IsChromeWeb bool `json:"isChromeWeb,omitempty"`
IsFirefox bool `json:"isFirefox,omitempty"`
IsSafari bool `json:"isSafari,omitempty"`
IsWpWns bool `json:"isWP_WNS,omitempty"`
IsAdm bool `json:"isAdm,omitempty"`
IsChrome bool `json:"isChrome,omitempty"`
ChannelForExternalUserIds string `json:"channel_for_external_user_ids,omitempty"`
}
// NotificationOpt model for request create a notification.
//
// For your reference, you can read this API reference on https://documentation.onesignal.com/reference/create-notification
type NotificationOpt struct {
AppID string `json:"app_id,omitempty"`
Filters []interface{} `json:"filters,omitempty"`
SpecificDevice
NotificationContent
EmailContent
Attachments
ActionButtons
Appearance
Delivery
Grouping
Platform
}
// AppsOpt model for request create an OneSignal application.
//
// For your reference, you can read this API reference on https://documentation.onesignal.com/reference/create-an-app
type AppsOpt struct {
Name string `json:"name,omitempty"`
ApnsEnv string `json:"apns_env,omitempty"`
ApnsP12 string `json:"apns_p12,omitempty"`
ApnsP12Password string `json:"apns_p12_password,omitempty"`
GcmKey string `json:"gcm_key,omitempty"`
AndroidGcmSenderID string `json:"android_gcm_sender_id,omitempty"`
ChromeWebOrigin string `json:"chrome_web_origin,omitempty"`
ChromeWebDefaultNotificationIcon string `json:"chrome_web_notification_icon,omitempty"`
ChromeWebSubDomain string `json:"chrome_web_sub_domain,omitempty"`
SafariApnsP12 string `json:"safari_apns_p12,omitempty"`
SafariApnsP12Password string `json:"safari_apns_p12_password,omitempty"`
SiteName string `json:"site_name,omitempty"`
SafariSiteOrigin string `json:"safari_site_origin,omitempty"`
SafariIcon256 string `json:"safari_icon_256_256,omitempty"`
ChromeKey string `json:"chrome_key,omitempty"`
AdditionalDataIsRootPayload bool `json:"additional_data_is_root_payload,omitempty"`
OrganizationID string `json:"organization_id,omitempty"`
}