package contract

import "time"

const (
	SettingIncomingLetterPrefix     = "INCOMING_LETTER_PREFIX"
	SettingIncomingLetterSequence   = "INCOMING_LETTER_SEQUENCE"
	SettingIncomingLetterRecipients = "INCOMING_LETTER_RECIPIENTS"
)

type ErrorResponse struct {
	Error   string                 `json:"error"`
	Message string                 `json:"message"`
	Details map[string]interface{} `json:"details,omitempty"`
	Code    int                    `json:"code"`
}

type ValidationErrorResponse struct {
	Error   string            `json:"error"`
	Message string            `json:"message"`
	Details map[string]string `json:"details"`
	Code    int               `json:"code"`
}

type SuccessResponse struct {
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

type PaginationRequest struct {
	Page  int `json:"page" validate:"min=1"`
	Limit int `json:"limit" validate:"min=1,max=100"`
}

type PaginationResponse struct {
	TotalCount int `json:"total_count"`
	Page       int `json:"page"`
	Limit      int `json:"limit"`
	TotalPages int `json:"total_pages"`
}

type SearchRequest struct {
	Query string `json:"query,omitempty"`
}

type DateRangeRequest struct {
	From *time.Time `json:"from,omitempty"`
	To   *time.Time `json:"to,omitempty"`
}

type HealthResponse struct {
	Status    string    `json:"status"`
	Timestamp time.Time `json:"timestamp"`
	Version   string    `json:"version"`
}

type LabelResponse struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Color     *string   `json:"color,omitempty"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type CreateLabelRequest struct {
	Name  string  `json:"name"`
	Color *string `json:"color,omitempty"`
}

type UpdateLabelRequest struct {
	Name  *string `json:"name,omitempty"`
	Color *string `json:"color,omitempty"`
}

type ListLabelsResponse struct {
	Labels []LabelResponse `json:"labels"`
}

type PriorityResponse struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Level     int       `json:"level"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type CreatePriorityRequest struct {
	Name  string `json:"name"`
	Level int    `json:"level"`
}

type UpdatePriorityRequest struct {
	Name  *string `json:"name,omitempty"`
	Level *int    `json:"level,omitempty"`
}

type ListPrioritiesResponse struct {
	Priorities []PriorityResponse `json:"priorities"`
}

type InstitutionResponse struct {
	ID            string    `json:"id"`
	Name          string    `json:"name"`
	Type          string    `json:"type"`
	Address       *string   `json:"address,omitempty"`
	ContactPerson *string   `json:"contact_person,omitempty"`
	Phone         *string   `json:"phone,omitempty"`
	Email         *string   `json:"email,omitempty"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
}

type CreateInstitutionRequest struct {
	Name          string  `json:"name"`
	Type          string  `json:"type"`
	Address       *string `json:"address,omitempty"`
	ContactPerson *string `json:"contact_person,omitempty"`
	Phone         *string `json:"phone,omitempty"`
	Email         *string `json:"email,omitempty"`
}

type UpdateInstitutionRequest struct {
	Name          *string `json:"name,omitempty"`
	Type          *string `json:"type,omitempty"`
	Address       *string `json:"address,omitempty"`
	ContactPerson *string `json:"contact_person,omitempty"`
	Phone         *string `json:"phone,omitempty"`
	Email         *string `json:"email,omitempty"`
}

type ListInstitutionsResponse struct {
	Institutions []InstitutionResponse `json:"institutions"`
}

type ListInstitutionsRequest struct {
	Search *string `json:"search,omitempty" form:"search"`
}

type DispositionActionResponse struct {
	ID           string    `json:"id"`
	Code         string    `json:"code"`
	Label        string    `json:"label"`
	Description  *string   `json:"description,omitempty"`
	RequiresNote bool      `json:"requires_note"`
	GroupName    *string   `json:"group_name,omitempty"`
	SortOrder    *int      `json:"sort_order,omitempty"`
	IsActive     bool      `json:"is_active"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

type CreateDispositionActionRequest struct {
	Code         string  `json:"code"`
	Label        string  `json:"label"`
	Description  *string `json:"description,omitempty"`
	RequiresNote *bool   `json:"requires_note,omitempty"`
	GroupName    *string `json:"group_name,omitempty"`
	SortOrder    *int    `json:"sort_order,omitempty"`
	IsActive     *bool   `json:"is_active,omitempty"`
}

type UpdateDispositionActionRequest struct {
	Code         *string `json:"code,omitempty"`
	Label        *string `json:"label,omitempty"`
	Description  *string `json:"description,omitempty"`
	RequiresNote *bool   `json:"requires_note,omitempty"`
	GroupName    *string `json:"group_name,omitempty"`
	SortOrder    *int    `json:"sort_order,omitempty"`
	IsActive     *bool   `json:"is_active,omitempty"`
}

type ListDispositionActionsResponse struct {
	Actions []DispositionActionResponse `json:"actions"`
}
