package response

import (
	"time"

	"gitlab.ost.ch/marketminds/marketminds/pkg/entity"
)

type namedEntity struct {
	Name       string      `json:"name"`
	EntityType string      `json:"entity_type"`
	CreatedAt  string      `json:"created_at"`
	NewsItems  []*newsItem `json:"news_items"`
}

func newNamedEntity(input *entity.NamedEntity) *namedEntity {
	var newsItems []*newsItem
	if input.NewsItems != nil {
		newsItems = newNewsItems(input.NewsItems)
	}

	return &namedEntity{
		Name:       input.Name,
		EntityType: input.EntityType,
		CreatedAt:  input.CreatedAt.UTC().Format(time.RFC3339),
		NewsItems:  newsItems,
	}
}
