2023-11-20 15:51:57 +00:00
|
|
|
using BotSharp.Abstraction.Conversations.Enums;
|
2023-08-19 00:15:02 +00:00
|
|
|
using BotSharp.Abstraction.Conversations.Models;
|
2023-11-14 01:25:25 +00:00
|
|
|
using BotSharp.OpenAPI.ViewModels.Users;
|
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
|
|
|
|
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
|
|
|
|
|
|
|
|
[JsonPropertyName("unread_msg_count")]
|
2023-11-14 04:56:06 +00:00
|
|
|
public int UnreadMsgCount { get; set; }
|
2023-11-15 13:33:46 +00:00
|
|
|
|
|
|
|
|
public string Event { get; set; }
|
|
|
|
|
|
2023-11-20 15:51:57 +00:00
|
|
|
public string Channel { get; set; } = ConversationChannel.OpenAPI;
|
2023-11-15 13:33:46 +00:00
|
|
|
public string Status { get; set; }
|
|
|
|
|
|
|
|
|
|
[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,
|
2023-11-20 15:51:57 +00:00
|
|
|
Channel = sess.Channel,
|
2023-11-15 13:33:46 +00:00
|
|
|
Status = sess.Status,
|
2023-08-19 00:15:02 +00:00
|
|
|
CreatedTime = sess.CreatedTime,
|
|
|
|
|
UpdatedTime = sess.UpdatedTime
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|