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