ImportedAgentViewModel

response more info after agent is imported.
This commit is contained in:
haiping008 2018-12-07 12:56:54 -06:00
parent a639e1210e
commit 9becfe5fde
3 changed files with 29 additions and 3 deletions

View file

@ -1,4 +1,6 @@
using BotSharp.Platform.Dialogflow.Models;
using BotSharp.Platform.Dialogflow.ViewModels;
using BotSharp.Platform.Models.Agents;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
@ -32,7 +34,8 @@ namespace BotSharp.Platform.Dialogflow.Controllers
/// <param name="file"></param>
/// <returns></returns>
[HttpPost("import")]
public async Task<ActionResult> Import(IFormFile uploadedFile)
[ProducesResponseType(typeof(ImportedAgentViewModel), 200)]
public async Task<IActionResult> Import(IFormFile uploadedFile)
{
if (uploadedFile == null || uploadedFile.Length == 0)
{
@ -61,7 +64,13 @@ namespace BotSharp.Platform.Dialogflow.Controllers
var agent = await builder.LoadAgentFromFile<AgentImporterInDialogflow<AgentModel>>(dest);
await builder.SaveAgent(agent);
return Ok(agent.Id);
return Ok(new ImportedAgentViewModel
{
Id = agent.Id,
Name = agent.Name,
Description = agent.Description,
ClientAccessToken = agent.ClientAccessToken
});
}
/// <summary>

View file

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace BotSharp.Platform.Models.Agents
{
public class ImportedAgentViewModel
{
public string Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string ClientAccessToken { get; set; }
}
}

View file

@ -11,7 +11,7 @@ namespace BotSharp.WebHost
{
public void Apply(Operation operation, OperationFilterContext context)
{
if (operation.OperationId == "V1AgentImportPost")
if (operation.OperationId == "Import")
{
operation.Parameters.Clear();