package receipt

import (
	"encoding/json"
	"time"
)

// Receipt is one complete Alertmanager webhook delivery. It is operational
// evidence, not the source for an alert's canonical business context.
type Receipt struct {
	ID                 int64           `db:"id" json:"id"`
	GroupKey           string          `db:"group_key" json:"group_key"`
	Receiver           string          `db:"receiver" json:"receiver"`
	Status             string          `db:"status" json:"status"`
	GroupLabels        json.RawMessage `db:"group_labels" json:"group_labels" swaggertype:"object"`
	CommonLabels       json.RawMessage `db:"common_labels" json:"common_labels" swaggertype:"object"`
	CommonAnnotations  json.RawMessage `db:"common_annotations" json:"common_annotations" swaggertype:"object"`
	ExternalURL        string          `db:"external_url" json:"external_url"`
	TruncatedAlerts    int             `db:"truncated_alerts" json:"truncated_alerts"`
	NotificationReason string          `db:"notification_reason" json:"notification_reason"`
	PayloadHash        string          `db:"payload_hash" json:"payload_hash"`
	RawPayload         json.RawMessage `db:"raw_payload" json:"raw_payload" swaggertype:"object"`
	ReceivedAt         time.Time       `db:"received_at" json:"received_at"`
}

type NewReceipt struct {
	GroupKey           string
	Receiver           string
	Status             string
	GroupLabels        map[string]string
	CommonLabels       map[string]string
	CommonAnnotations  map[string]string
	ExternalURL        string
	TruncatedAlerts    int
	NotificationReason string
	RawPayload         json.RawMessage
}
