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"`
	Details   string `json:"details"`
	Section   string `json:"section"`
	Affected  bool   `json:"affected"`
	Reference string `json:"reference"`
}

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