dukcapil/internal/contract/notification_contract.go
2025-09-08 12:24:37 +07:00

107 lines
3.6 KiB
Go

package contract
import "github.com/google/uuid"
type TriggerNotificationRequest struct {
UserID uuid.UUID `json:"user_id" validate:"required"`
TemplateID string `json:"template_id" validate:"required"`
TemplateData map[string]interface{} `json:"template_data,omitempty"`
To *NotificationTo `json:"to,omitempty"`
Overrides *NotificationOverrides `json:"overrides,omitempty"`
}
type NotificationTo struct {
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
SubscriberID string `json:"subscriber_id,omitempty"`
}
type NotificationOverrides struct {
Email *EmailOverride `json:"email,omitempty"`
SMS *SMSOverride `json:"sms,omitempty"`
InApp *InAppOverride `json:"in_app,omitempty"`
Push *PushOverride `json:"push,omitempty"`
Chat *ChatOverride `json:"chat,omitempty"`
}
type EmailOverride struct {
Subject string `json:"subject,omitempty"`
Body string `json:"body,omitempty"`
From string `json:"from,omitempty"`
}
type SMSOverride struct {
Content string `json:"content,omitempty"`
From string `json:"from,omitempty"`
}
type InAppOverride struct {
Content string `json:"content,omitempty"`
}
type PushOverride struct {
Title string `json:"title,omitempty"`
Content string `json:"content,omitempty"`
}
type ChatOverride struct {
Content string `json:"content,omitempty"`
}
type TriggerNotificationResponse struct {
Success bool `json:"success"`
TransactionID string `json:"transaction_id,omitempty"`
Message string `json:"message,omitempty"`
}
type BulkTriggerNotificationRequest struct {
TemplateID string `json:"template_id" validate:"required"`
UserIDs []uuid.UUID `json:"user_ids" validate:"required,min=1"`
TemplateData map[string]interface{} `json:"template_data,omitempty"`
Overrides *NotificationOverrides `json:"overrides,omitempty"`
}
type BulkTriggerNotificationResponse struct {
Success bool `json:"success"`
TotalSent int `json:"total_sent"`
TotalFailed int `json:"total_failed"`
Results []NotificationResult `json:"results,omitempty"`
}
type NotificationResult struct {
UserID uuid.UUID `json:"user_id"`
Success bool `json:"success"`
TransactionID string `json:"transaction_id,omitempty"`
Error string `json:"error,omitempty"`
}
type GetSubscriberRequest struct {
UserID uuid.UUID `json:"user_id" validate:"required"`
}
type GetSubscriberResponse struct {
SubscriberID string `json:"subscriber_id"`
Email string `json:"email"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Phone string `json:"phone,omitempty"`
Avatar string `json:"avatar,omitempty"`
Data map[string]interface{} `json:"data,omitempty"`
Channels []ChannelCredentials `json:"channels,omitempty"`
}
type ChannelCredentials struct {
Channel string `json:"channel"`
Credentials map[string]interface{} `json:"credentials"`
}
type UpdateSubscriberChannelRequest struct {
UserID uuid.UUID `json:"user_id" validate:"required"`
Channel string `json:"channel" validate:"required,oneof=email sms push chat in_app"`
Credentials map[string]interface{} `json:"credentials" validate:"required"`
}
type UpdateSubscriberChannelResponse struct {
Success bool `json:"success"`
Message string `json:"message,omitempty"`
}