notification/model.go

130 lines
2.9 KiB
Go

package notification
import "git.selly.red/Selly-Modules/natsio"
// Config ...
type Config struct {
APIKey string
Nats natsio.Config
}
// PushRequest ...
type PushRequest struct {
Title string `json:"title"`
Body string `json:"body"`
Data string `json:"data"`
Users []string `json:"users"`
Label string `json:"label,omitempty"`
Category string `json:"category,omitempty"`
Sound *Sound `json:"sound,omitempty"`
Link string `json:"link"` // for webpush
Order int `json:"order"` // for sort
DisplayUntil int64 `json:"displayUntil"` // time.Unix
SaveNotification bool `json:"saveNotification"`
}
// Sound ...
type Sound struct {
IOSFileName string `json:"iosFileName"`
AndroidChannel string `json:"androidChannel"`
}
// PushResponse ...
type PushResponse struct {
RequestID string `json:"requestId"`
}
type pushRequest struct {
PushRequest
Version string `json:"version"`
APIKey string `json:"apiKey"`
SendBy string `json:"sendBy"`
}
// Query ...
type Query struct {
User string `json:"user"`
Category string `json:"category,omitempty"`
Status string `json:"status"`
Page int64 `json:"page,omitempty"`
Limit int64 `json:"limit,omitempty"`
Sort string `json:"sort,omitempty"` // SortDefault, SortOrderDesc, SortOrderAsc
}
type query struct {
APIKey string `json:"apiKey"`
Query
}
// Notification ...
type Notification struct {
ID string `json:"id"`
Category string `json:"category,omitempty"`
Title string `json:"title"`
Body string `json:"body"`
IsRead bool `json:"isRead"`
Data string `json:"data,omitempty"`
CreatedAt string `json:"createdAt"`
LastPushAt string `json:"lastPushAt"`
}
// ListNotificationResponse ...
type ListNotificationResponse struct {
List []Notification `json:"list"`
Total int64 `json:"total"`
Limit int64 `json:"limit"`
}
// Read ...
type Read struct {
ID string `json:"id"`
}
type read struct {
APIKey string `json:"apiKey"`
ID string `json:"id"`
}
// CountUnread ...
type CountUnread struct {
User string `json:"user"`
Category string `json:"category,omitempty"`
}
// CountUnreadResponse ...
type CountUnreadResponse struct {
List []CategoryCount `json:"list"`
}
type CategoryCount struct {
Category string `json:"category"`
TotalUnread int64 `json:"totalUnread"`
}
type countUnread struct {
CountUnread
APIKey string `json:"apiKey"`
}
// CommonError ...
type CommonError struct {
Error string `json:"error"`
}
// Subscribe ...
type Subscribe struct {
Tokens []string `json:"tokens"`
Topic string `json:"topic"`
}
type subscribe struct {
Subscribe
APIKey string `json:"apiKey"`
}
// ReadAll ...
type ReadAll struct {
User string `json:"user"`
Category string `json:"category,omitempty"`
}