package usecase

import (
	domentity "gateway/internal/model/notification/domain/entity"
	domusecase "gateway/internal/model/notification/domain/usecase"
)

func entityToDTO(doc *domentity.Notification) *domusecase.NotificationDTO {
	if doc == nil {
		return nil
	}
	dto := &domusecase.NotificationDTO{
		ID:                doc.ID.Hex(),
		TenantID:          doc.TenantID,
		UID:               doc.UID,
		Channel:           doc.Channel,
		Kind:              doc.Kind,
		TargetHash:        doc.TargetHash,
		TemplateKey:       doc.TemplateKey,
		Locale:            doc.Locale,
		Provider:          doc.Provider,
		ProviderMessageID: doc.ProviderMessageID,
		Status:            doc.Status,
		Attempts:          doc.Attempts,
		LastError:         doc.LastError,
		IdempotencyKey:    doc.IdempotencyKey,
		Severity:          doc.Severity,
	}
	if doc.OccurredAt != nil {
		dto.OccurredAt = *doc.OccurredAt
	}
	if doc.DeliveredAt != nil {
		dto.DeliveredAt = *doc.DeliveredAt
	}
	return dto
}
