using System.Text.Json.Serialization;
using AnthropicClient.Utils;
namespace AnthropicClient.Models;
///
/// Represents text content that is part of a message.
///
public class TextContent : Content
{
///
/// Gets the text of the content.
///
public string Text { get; init; } = string.Empty;
[JsonConstructor]
internal TextContent() : base(ContentType.Text)
{
}
private void Validate(string text)
{
ArgumentValidator.ThrowIfNull(text, nameof(text));
}
///
/// Initializes a new instance of the class.
///
/// The text of the content.
/// Thrown when the text is null.
/// A new instance of the class.
public TextContent(string text) : base(ContentType.Text)
{
Validate(text);
Text = text;
}
///
/// Initializes a new instance of the class.
///
/// The text of the content.
/// The cache control to be used for the content.
/// A new instance of the class.
/// Thrown when the text or cache control is null.
public TextContent(string text, CacheControl cacheControl) : base(ContentType.Text, cacheControl)
{
Validate(text);
Text = text;
}
}