package schema

import (
	"time"

	"entgo.io/ent"
	"entgo.io/ent/schema/field"
)

// Service holds the schema definition for the Service entity.
type Service struct {
	ent.Schema
}

type TosHighlight struct {
	Title     string `json:"title"`
	Text      string `json:"text"`
	Section   string `json:"section"`
	Reference string `json:"reference"`
}

// Fields of the Service.
func (Service) Fields() []ent.Field {
	return []ent.Field{
		field.String("name").NotEmpty().Unique().StructTag(`json:"name"`),
		field.String("description").NotEmpty().StructTag(`json:"description"`),
		field.String("logo_url").NotEmpty().StructTag(`json:"logo_url"`),
		field.String("referral").Default("").StructTag(`json:"referral"`),
		field.String("category").Default("others").StructTag(`json:"category"`),
		field.String("listing_comment").Default("").StructTag(`json:"listing_comment"`),
		field.String("tags").StructTag(`json:"tags"`),
		field.Strings("urls").StructTag(`json:"urls"`),
		field.Strings("tos_urls").StructTag(`json:"tos_urls"`),
		field.Strings("onion_urls").StructTag(`json:"onion_urls"`),
		field.String("attributes").Default("").StructTag(`json:"attributes"`),
		field.Int("kyc_level").Default(0).StructTag(`json:"kyc_level"`),
		field.Bool("pending").Default(true).StructTag(`json:"pending"`),
		field.Bool("listed").Default(false).StructTag(`json:"listed"`),
		field.Bool("verified").Default(false).StructTag(`json:"verified"`),
		field.Bool("xmr").Default(false).StructTag(`json:"xmr"`),
		field.Bool("btc").Default(false).StructTag(`json:"btc"`),
		field.Bool("lightning").Default(false).StructTag(`json:"lightning"`),
		field.Bool("fiat").Default(false).StructTag(`json:"fiat"`),
		field.Bool("cash").Default(false).StructTag(`json:"cash"`),
		field.Enum("type").Values("exchange", "service", "wallet").StructTag(`json:"type"`).Default("service"),
		field.Time("created_at").Default(time.Now).Immutable().StructTag(`json:"created_at"`),
		field.JSON("tos_highlights", &[]TosHighlight{}).Optional().StructTag(`json:"tos_highlights"`),
	}
}
