package response

import (
	"time"

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

type sentimentResult struct {
	TitlePositive       float32 `json:"title_positive"`
	TitleNeutral        float32 `json:"title_neutral"`
	TitleNegative       float32 `json:"title_negative"`
	DescriptionPositive float32 `json:"description_positive"`
	DescriptionNeutral  float32 `json:"description_neutral"`
	DescriptionNegative float32 `json:"description_negative"`
	CreatedAt           string  `json:"created_at"`
}

func newSentimentResult(input *entity.SentimentResult) *sentimentResult {
	var createdAt string = ""
	if !input.CreatedAt.IsZero() {
		createdAt = input.CreatedAt.UTC().Format(time.RFC3339)
	}

	return &sentimentResult{
		TitlePositive:       input.TitlePositive,
		TitleNeutral:        input.TitleNeutral,
		TitleNegative:       input.TitleNegative,
		DescriptionPositive: input.DescriptionPositive,
		DescriptionNeutral:  input.DescriptionNeutral,
		DescriptionNegative: input.DescriptionNegative,
		CreatedAt:           createdAt,
	}
}
