BotSharp/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Conversations/ConversationViewModel.cs

56 lines
1.5 KiB
C#
Raw Normal View History

2023-11-15 13:33:46 +00:00
using System.Text.Json.Serialization;
2023-08-19 00:15:02 +00:00
namespace BotSharp.OpenAPI.ViewModels.Conversations;
public class ConversationViewModel
{
public string Id { get; set; }
2023-11-15 13:33:46 +00:00
[JsonPropertyName("agent_id")]
2023-08-19 00:15:02 +00:00
public string AgentId { get; set; }
2023-11-15 13:33:46 +00:00
2024-01-28 01:02:33 +00:00
[JsonPropertyName("agent_name")]
public string AgentName { get; set; }
2023-08-19 00:15:02 +00:00
public string Title { get; set; } = string.Empty;
2023-11-15 13:33:46 +00:00
2023-11-14 01:25:25 +00:00
public UserViewModel User { get; set; } = new UserViewModel();
2023-11-15 13:33:46 +00:00
public string Event { get; set; }
public string Channel { get; set; } = ConversationChannel.OpenAPI;
2024-02-12 15:14:33 +00:00
/// <summary>
/// Agent task id
/// </summary>
[JsonPropertyName("task_id")]
public string? TaskId { get; set; }
2023-11-15 13:33:46 +00:00
public string Status { get; set; }
2024-01-02 17:40:08 +00:00
public Dictionary<string, string> States { get; set; }
2023-11-15 13:33:46 +00:00
[JsonPropertyName("updated_time")]
2023-08-19 00:15:02 +00:00
public DateTime UpdatedTime { get; set; } = DateTime.UtcNow;
2023-11-15 13:33:46 +00:00
[JsonPropertyName("created_time")]
2023-08-19 00:15:02 +00:00
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
public static ConversationViewModel FromSession(Conversation sess)
{
return new ConversationViewModel
{
Id = sess.Id,
2023-11-14 01:25:25 +00:00
User = new UserViewModel
{
Id = sess.UserId
},
2023-08-19 00:15:02 +00:00
AgentId = sess.AgentId,
Title = sess.Title,
Channel = sess.Channel,
2023-11-15 13:33:46 +00:00
Status = sess.Status,
2024-02-12 15:14:33 +00:00
TaskId = sess.TaskId,
2023-08-19 00:15:02 +00:00
CreatedTime = sess.CreatedTime,
UpdatedTime = sess.UpdatedTime
};
}
}