package v1

import (
	"encoding/json"

	"github.com/pingcap-inc/pinsights/internal/larkbot/store"
)

type Service interface {
	Validate() ValidateSrv
	WhiteList() WhiteListSrv
	Contact() ContactSrv
}

type service struct {
	store store.Factory
}

type EventSchemaHeader struct {
	EventId    string `json:"eventId"`
	Token      string `json:"token"`
	CreateTime string `json:"createTime"`
	EventType  string `json:"eventType"`
	TenantKey  string `json:"tenantKey"`
	AppId      string `json:"appId"`
}

type EventSchemaV2 struct {
	Schema string            `json:"schema"`
	Header EventSchemaHeader `json:"header"`
	Event  json.RawMessage   `json:"event"`
}

func NewService(store store.Factory) Service {
	return &service{
		store: store,
	}
}

func (s *service) Validate() ValidateSrv {
	return newValidateSrv(s)
}

func (s *service) WhiteList() WhiteListSrv {
	return newWhiteListSrv(s)
}

func (s *service) Contact() ContactSrv {
	return newContactSrv(s)
}
