package store

import (
	"database/sql"
	"time"
)

// Integration represents an external service connection
type Integration struct {
	ID                   string    `json:"id"`
	WorkspaceSlug        string    `json:"workspaceSlug"`
	Provider             string    `json:"provider"`
	Name                 string    `json:"name"`
	Config               string    `json:"config"`
	Status               string    `json:"status"`
	LastSyncAt           *time.Time `json:"lastSyncAt,omitempty"`
	CreatedAt            time.Time `json:"createdAt"`
	UpdatedAt            time.Time `json:"updatedAt"`
}

// Webhook represents an external webhook endpoint
type Webhook struct {
	ID              string    `json:"id"`
	WorkspaceSlug   string    `json:"workspaceSlug"`
	Name            string    `json:"name"`
	URL             string    `json:"url"`
	Events          string    `json:"events"` // JSON array
	Active          bool      `json:"active"`
	LastTriggeredAt *time.Time `json:"lastTriggeredAt,omitempty"`
	CreatedAt       time.Time `json:"createdAt"`
	UpdatedAt       time.Time `json:"updatedAt"`
}

// Notification represents a user notification
type Notification struct {
	ID            string    `json:"id"`
	WorkspaceSlug string    `json:"workspaceSlug"`
	UserEmail     string    `json:"userEmail"`
	Type          string    `json:"type"`
	Title         string    `json:"title"`
	Body          string    `json:"body"`
	EntityType    *string   `json:"entityType,omitempty"`
	EntityID      *string   `json:"entityId,omitempty"`
	Read          bool      `json:"read"`
	CreatedAt     time.Time `json:"createdAt"`
}

// Presence represents a user's real-time presence
type Presence struct {
	ID            string    `json:"id"`
	WorkspaceSlug string    `json:"workspaceSlug"`
	UserEmail     string    `json:"userEmail"`
	UserName      string    `json:"userName"`
	EntityType    *string   `json:"entityType,omitempty"`
	EntityID      *string   `json:"entityId,omitempty"`
	LastSeenAt    time.Time `json:"lastSeenAt"`
	CreatedAt     time.Time `json:"createdAt"`
}

// CreateIntegrationInput for creating integrations
type CreateIntegrationInput struct {
	WorkspaceSlug string `json:"workspaceSlug" binding:"required"`
	Provider      string `json:"provider" binding:"required"`
	Name          string `json:"name" binding:"required"`
	Config        string `json:"config"`
	Credentials   string `json:"credentials" binding:"required"`
}

// CreateWebhookInput for creating webhooks
type CreateWebhookInput struct {
	WorkspaceSlug string `json:"workspaceSlug" binding:"required"`
	Name          string `json:"name" binding:"required"`
	URL           string `json:"url" binding:"required"`
	Events        string `json:"events"` // JSON array
}

// CreateNotificationInput for creating notifications
type CreateNotificationInput struct {
	WorkspaceSlug string  `json:"workspaceSlug" binding:"required"`
	UserEmail     string  `json:"userEmail" binding:"required"`
	Type          string  `json:"type" binding:"required"`
	Title         string  `json:"title" binding:"required"`
	Body          string  `json:"body"`
	EntityType    *string `json:"entityType"`
	EntityID      *string `json:"entityId"`
}

// UpdatePresenceInput for updating presence
type UpdatePresenceInput struct {
	WorkspaceSlug string  `json:"workspaceSlug" binding:"required"`
	UserEmail     string  `json:"userEmail" binding:"required"`
	UserName      string  `json:"userName" binding:"required"`
	EntityType    *string `json:"entityType"`
	EntityID      *string `json:"entityId"`
}