using System.Text.Json.Serialization; using AnthropicClient.Utils; namespace AnthropicClient.Models; /// /// Represents a message. /// public class Message { /// /// Gets the role of the message. /// public string Role { get; init; } = string.Empty; /// /// Gets the contents of the message. /// public List Content { get; init; } = []; [JsonConstructor] internal Message() { } /// /// Initializes a new instance of the class. /// /// The role of the message. /// The contents of the message. /// Thrown when the role is invalid. /// Thrown when the role or content is null. /// A new instance of the class. public Message(string role, List content) { ArgumentValidator.ThrowIfNull(role, nameof(role)); ArgumentValidator.ThrowIfNull(content, nameof(content)); if (MessageRole.IsValidRole(role) is false) { throw new ArgumentException($"Invalid role: {role}"); } Role = role; Content = content; } }