package domain

import (
	"fmt"

	"github.com/jackc/pgx/v5/pgtype"
)

type ReportRequestType string

var (
	EventIntervalReportRequest ReportRequestType = "event_interval"
	// EventBetReportRequest        ReportRequestType = "event_bet"
	CompanyIntervalReportRequest ReportRequestType = "company_interval"
	BranchIntervalReportRequest  ReportRequestType = "branch_interval"
	BetIntervalReportRequest     ReportRequestType = "bet_interval"
	WalletIntervalReportRequest  ReportRequestType = "wallet_interval"
)

func (r ReportRequestType) IsValid() bool {
	switch r {
	case EventIntervalReportRequest, CompanyIntervalReportRequest:
		return true
	default:
		return false
	}
}

func ParseReportRequestType(val string) (ReportRequestType, error) {
	r := ReportRequestType(val)
	if !r.IsValid() {
		return "", fmt.Errorf("invalid ReportRequestType: %q", val)
	}
	return r, nil
}

type ValidReportRequestType struct {
	Value ReportRequestType
	Valid bool
}

func (v ValidReportRequestType) ToPG() pgtype.Text {
	return pgtype.Text{
		String: string(v.Value),
		Valid:  v.Valid,
	}
}
