Skip to content

Commit 9becfe5

Browse files
committed
ImportedAgentViewModel
response more info after agent is imported.
1 parent a639e12 commit 9becfe5

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

BotSharp.Platform.Dialogflow/Controllers/AgentController.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using BotSharp.Platform.Dialogflow.Models;
2+
using BotSharp.Platform.Dialogflow.ViewModels;
3+
using BotSharp.Platform.Models.Agents;
24
using Microsoft.AspNetCore.Http;
35
using Microsoft.AspNetCore.Mvc;
46
using System;
@@ -32,7 +34,8 @@ public AgentController(DialogflowAi<AgentModel> platform)
3234
/// <param name="file"></param>
3335
/// <returns></returns>
3436
[HttpPost("import")]
35-
public async Task<ActionResult> Import(IFormFile uploadedFile)
37+
[ProducesResponseType(typeof(ImportedAgentViewModel), 200)]
38+
public async Task<IActionResult> Import(IFormFile uploadedFile)
3639
{
3740
if (uploadedFile == null || uploadedFile.Length == 0)
3841
{
@@ -61,7 +64,13 @@ public async Task<ActionResult> Import(IFormFile uploadedFile)
6164
var agent = await builder.LoadAgentFromFile<AgentImporterInDialogflow<AgentModel>>(dest);
6265
await builder.SaveAgent(agent);
6366

64-
return Ok(agent.Id);
67+
return Ok(new ImportedAgentViewModel
68+
{
69+
Id = agent.Id,
70+
Name = agent.Name,
71+
Description = agent.Description,
72+
ClientAccessToken = agent.ClientAccessToken
73+
});
6574
}
6675

6776
/// <summary>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace BotSharp.Platform.Models.Agents
6+
{
7+
public class ImportedAgentViewModel
8+
{
9+
public string Id { get; set; }
10+
11+
public string Name { get; set; }
12+
13+
public string Description { get; set; }
14+
15+
public string ClientAccessToken { get; set; }
16+
}
17+
}

BotSharp.WebHost/SwaggerFileUploadOperation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class SwaggerFileUploadOperation : IOperationFilter
1111
{
1212
public void Apply(Operation operation, OperationFilterContext context)
1313
{
14-
if (operation.OperationId == "V1AgentImportPost")
14+
if (operation.OperationId == "Import")
1515
{
1616
operation.Parameters.Clear();
1717

0 commit comments

Comments
 (0)