using System.Text.Json.Serialization;
using AnthropicClient.Utils;
namespace AnthropicClient.Models;
///
/// Represents an image source.
///
public class ImageSource
{
///
/// Gets the media type of the image.
///
[JsonPropertyName("media_type")]
public string MediaType { get; init; } = string.Empty;
///
/// Gets the data of the image.
///
public string Data { get; init; } = string.Empty;
///
/// Gets the type of encoding of the image data.
///
public string Type { get; init; } = "base64";
[JsonConstructor]
internal ImageSource()
{
}
///
/// Initializes a new instance of the class.
///
/// The media type of the image.
/// The data of the image.
/// Thrown when the media type is invalid.
/// Thrown when the media type or data is null.
/// A new instance of the class.
public ImageSource(string mediaType, string data)
{
ArgumentValidator.ThrowIfNull(mediaType, nameof(mediaType));
if (ImageType.IsValidImageType(mediaType) is false)
{
throw new ArgumentException($"Invalid media type: {mediaType}");
}
ArgumentValidator.ThrowIfNull(data, nameof(data));
MediaType = mediaType;
Data = data;
}
}