package request

import "narasi-ahli-be/app/database/entity"

type AgentCreateRequest struct {
	AgentID      string `json:"agent_id" validate:"required"`
	Name         string `json:"name" validate:"required"`
	Description  string `json:"description"`
	Instructions string `json:"instructions"`
	Type         string `json:"type" validate:"required"`
	Status       *bool  `json:"status"`
	IsActive     *bool  `json:"is_active"`
}

func (r *AgentCreateRequest) ToEntity() *entity.Agent {
	status := true
	if r.Status != nil {
		status = *r.Status
	}

	isActive := true
	if r.IsActive != nil {
		isActive = *r.IsActive
	}

	return &entity.Agent{
		AgentID:      r.AgentID,
		Name:         r.Name,
		Description:  r.Description,
		Instructions: r.Instructions,
		Type:         r.Type,
		Status:       status,
		IsActive:     isActive,
	}
}

type AgentUpdateRequest struct {
	Name         *string `json:"name"`
	Description  *string `json:"description"`
	Instructions *string `json:"instructions"`
	Type         *string `json:"type"`
	Status       *bool   `json:"status"`
	IsActive     *bool   `json:"is_active"`
}

func (r *AgentUpdateRequest) ToMap() map[string]interface{} {
	data := map[string]interface{}{}

	if r.Name != nil {
		data["name"] = *r.Name
	}
	if r.Description != nil {
		data["description"] = *r.Description
	}
	if r.Instructions != nil {
		data["instructions"] = *r.Instructions
	}
	if r.Type != nil {
		data["type"] = *r.Type
	}
	if r.Status != nil {
		data["status"] = *r.Status
	}
	if r.IsActive != nil {
		data["is_active"] = *r.IsActive
	}

	return data
}

type AgentQueryRequest struct {
	Name   string `query:"name"`
	Type   string `query:"type"`
	Status *bool  `query:"status"`
}
