package notification import ( "tm/pkg/response" "go.mongodb.org/mongo-driver/v2/bson" ) // CreateRequest represents the request to create a notification type NotificationRequest struct { Recipient []string `json:"recipient" valid:"required,stringlength(1|100)"` Tender bson.ObjectID `json:"tender" valid:"optional,stringlength(1|100)"` Channels []DeliveryChannel `json:"channels" valid:"required,minlength(1)"` Type NotificationType `json:"type" valid:"required,notification_type"` Priority NotificationPriority `json:"priority" valid:"required,notification_priority"` Target TargetAudienceType `json:"target" valid:"required,target_audience"` Title string `json:"title" valid:"required,stringlength(1|200)"` Description string `json:"description" valid:"required,stringlength(1|1000)"` Link *string `json:"link" valid:"optional,url"` Schedule ScheduleRequest `json:"schedule" valid:"optional"` } type ScheduleRequest struct { Time int64 `json:"time" valid:"required,int64"` } // NotificationResponse represents the response after creating a notification type NotificationResponse struct { ID string `json:"id"` Tender string `json:"tender"` Channels []DeliveryChannel `json:"channels"` Type NotificationType `json:"type"` Priority NotificationPriority `json:"priority"` Target TargetAudienceType `json:"target"` Title string `json:"title"` Description string `json:"description"` Link string `json:"link"` Schedule ScheduleResponse `json:"schedule"` } type ScheduleResponse struct { Time int64 `json:"time"` } type NotificationsResponse struct { Notifications []*NotificationResponse `json:"notifications"` Meta *response.Meta `json:"-"` } func (n *Notification) ToResponse() *NotificationResponse { return &NotificationResponse{ ID: n.ID.Hex(), Tender: n.Tender.Hex(), Channels: n.Channels, Type: n.Type, Priority: n.Priority, Target: n.Target, Title: n.Title, Description: n.Description, Link: *n.Link, Schedule: ScheduleResponse{ Time: n.Schedule.Time, }, } } // SearchForm represents the form for searching notifications type SearchForm struct { Search *string `query:"q" valid:"optional"` }