package repository

import (
	"context"
	"time"

	"gitea.computernetthings.ru/yash/crypto_alert_bot/internal/entities"
	"github.com/shopspring/decimal"
)

type Storage interface {
	SaveUser(ctx context.Context, user *entities.User) (entities.UserID, error)
	UserByID(ctx context.Context, id entities.UserID) (*entities.User, error)
	UserByTelegramID(ctx context.Context, tgID entities.TelegramID) (*entities.User, error)

	InstrumentList(ctx context.Context, offset, limit int) ([]entities.Instrument, error)
	CreateInstrument(ctx context.Context, instrument *entities.Instrument) (entities.InstrumentID, error)

	SaveAlert(ctx context.Context, alert *entities.Alert) (entities.AlertID, error)
	AllActiveAlerts(ctx context.Context) ([]entities.Alert, error)
	AlertByID(ctx context.Context, id entities.AlertID) (*entities.Alert, error)
	AlertsByUserID(ctx context.Context, userID entities.UserID, offset, limit int) ([]entities.Alert, error)
	DeleteAlert(ctx context.Context, id entities.AlertID) error
	DisableAlert(ctx context.Context, id entities.AlertID) error
	UpdateAlertPrice(ctx context.Context, id entities.AlertID, price decimal.Decimal) error

	// GetLastAlertCheck returns the time of the last completed alert check.
	// Returns zero time if no check has been recorded yet.
	GetLastAlertCheck(ctx context.Context) (time.Time, error)
	SetLastAlertCheck(ctx context.Context, t time.Time) error
}
