package model

import paymenttypes "github.com/tech/sendico/pkg/payments/types"

type ConfirmationStatus string

const (
	ConfirmationStatusConfirmed ConfirmationStatus = "CONFIRMED"
	ConfirmationStatusClarified ConfirmationStatus = "CLARIFIED"
	ConfirmationStatusTimeout   ConfirmationStatus = "TIMEOUT"
	ConfirmationStatusRejected  ConfirmationStatus = "REJECTED"
)

type ConfirmationRequest struct {
	RequestID       string              `bson:"requestId,omitempty" json:"request_id,omitempty"`
	TargetChatID    string              `bson:"targetChatId,omitempty" json:"target_chat_id,omitempty"`
	RequestedMoney  *paymenttypes.Money `bson:"requestedMoney,omitempty" json:"requested_money,omitempty"`
	PaymentIntentID string              `bson:"paymentIntentId,omitempty" json:"payment_intent_id,omitempty"`
	QuoteRef        string              `bson:"quoteRef,omitempty" json:"quote_ref,omitempty"`
	AcceptedUserIDs []string            `bson:"acceptedUserIds,omitempty" json:"accepted_user_ids,omitempty"`
	TimeoutSeconds  int32               `bson:"timeoutSeconds,omitempty" json:"timeout_seconds,omitempty"`
	SourceService   string              `bson:"sourceService,omitempty" json:"source_service,omitempty"`
	Rail            string              `bson:"rail,omitempty" json:"rail,omitempty"`
	OperationRef    string              `bson:"operationRef,omitempty" json:"operation_ref,omitempty"`
	IntentRef       string              `bson:"intentRef,omitempty" json:"intent_ref,omitempty"`
	PaymentRef      string              `bson:"paymentRef,omitempty" json:"payment_ref,omitempty"`
}

type ConfirmationResult struct {
	RequestID  string              `bson:"requestId,omitempty" json:"request_id,omitempty"`
	Money      *paymenttypes.Money `bson:"money,omitempty" json:"money,omitempty"`
	RawReply   *TelegramMessage    `bson:"rawReply,omitempty" json:"raw_reply,omitempty"`
	Status     ConfirmationStatus  `bson:"status,omitempty" json:"status,omitempty"`
	ParseError string              `bson:"parseError,omitempty" json:"parse_error,omitempty"`
}

// ConfirmationRequestDispatch is emitted by the notification service after it sends
// a confirmation prompt message to Telegram.
type ConfirmationRequestDispatch struct {
	RequestID     string `bson:"requestId,omitempty" json:"request_id,omitempty"`
	ChatID        string `bson:"chatId,omitempty" json:"chat_id,omitempty"`
	MessageID     string `bson:"messageId,omitempty" json:"message_id,omitempty"`
	Rail          string `bson:"rail,omitempty" json:"rail,omitempty"`
	SourceService string `bson:"sourceService,omitempty" json:"source_service,omitempty"`
}
