using Microsoft.AspNetCore.Mvc;
using ms_namingservice.Mapping;
using ms_namingservice.Mapping.ValuesMapping.TempMapping;
using ms_namingservice.Objects.SavedData;
using ms_namingservice.Objects.ServiceObjects;

namespace ms_namingservice.Controllers;

/// <summary>
/// Controller for generating web requests related to naming.
/// </summary>
[ApiController]
[Route("[controller]")]
public class WebController : ControllerBase
{
    /// <summary>
    /// Generates names, categories, subcategories, references and returning log sources based on input object.
    /// </summary>
    /// <param name="input">The input object to generate names from</param>
    /// <returns>The generated output including generated names</returns>
    [HttpPost]
    [Route("/naming")]
    public async Task<Output> GenerateNames([FromBody] Input input)
    {
        Input convertedInput = TagFixing.GetConvertedTagInput(input); //Fixing problems with tags[] array
        InputData.Input = convertedInput; //Saving the data into static object
        Output output = await GeneratingNames.GetResult(); //Getting the results
        return output;
    }
}