package dto_admin

// Notifications the admin panel triggers.
//
// Two shapes, because there are two kinds of trigger:
//
//   - **A message the admin writes.** The panel supplies the words.
//   - **An event the panel handled.** Profile verification and withdrawal
//     approval are decided in the panel, not in this API, so the panel tells
//     the API what it did and the API sends the notification with the same
//     wording every other notification uses. That keeps one set of templates
//     rather than the panel inventing its own copy.

//------------------------------------------------
// Admin message
//------------------------------------------------

// Audience values for SendNotificationRequest.
const (
	AudienceCustomer       = "CUSTOMER"
	AudienceAstrologer     = "ASTROLOGER"
	AudienceAllCustomers   = "ALL_CUSTOMERS"
	AudienceAllAstrologers = "ALL_ASTROLOGERS"
)

type SendNotificationRequest struct {
	// CUSTOMER | ASTROLOGER | ALL_CUSTOMERS | ALL_ASTROLOGERS
	Audience string `json:"audience" binding:"required"`

	// Required for CUSTOMER — the customer's users.id.
	UserID uint `json:"user_id"`

	// Required for ASTROLOGER — the astrologers.id, not the login id. The API
	// resolves it to the linked user account.
	AstrologerID uint `json:"astrologer_id"`

	Title string `json:"title" binding:"required"`
	Body  string `json:"body" binding:"required"`

	// Caps a broadcast, for a staged rollout. 0 means everybody.
	Limit int `json:"limit"`
}

type SendNotificationResponse struct {
	Audience string `json:"audience"`

	// How many accounts the notification was queued for. Delivery itself is
	// asynchronous and per device, so this is recipients, not handsets.
	RecipientCount int `json:"recipient_count"`

	Queued bool `json:"queued"`
}

//------------------------------------------------
// Panel-handled events
//------------------------------------------------

// Event values for NotifyEventRequest.
const (
	EventProfileApproved  = "PROFILE_APPROVED"
	EventProfileRejected  = "PROFILE_REJECTED"
	EventWithdrawApproved = "WITHDRAW_APPROVED"
	EventWithdrawRejected = "WITHDRAW_REJECTED"
)

type NotifyEventRequest struct {
	// PROFILE_APPROVED | PROFILE_REJECTED | WITHDRAW_APPROVED |
	// WITHDRAW_REJECTED
	Event string `json:"event" binding:"required"`

	// The astrologers.id the event is about. All four events target an
	// astrologer.
	AstrologerID uint `json:"astrologer_id" binding:"required"`

	// Withdrawal events: the amount the notification quotes.
	Amount float64 `json:"amount"`

	// WITHDRAW_APPROVED: the bank or UPI reference to show the astrologer.
	Reference string `json:"reference"`

	// PROFILE_REJECTED / WITHDRAW_REJECTED: why. Shown verbatim, so write it
	// for the astrologer to read.
	Reason string `json:"reason"`
}

type NotifyEventResponse struct {
	Event        string `json:"event"`
	AstrologerID uint   `json:"astrologer_id"`
	Queued       bool   `json:"queued"`
}
