2024-06-27 23:26:53 -05:00
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
|
|
|
|
|
namespace AnthropicClient.Models;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents an image source.
|
|
|
|
|
/// </summary>
|
2025-06-14 13:44:10 -05:00
|
|
|
public class ImageSource : Base64Source
|
2024-06-27 23:26:53 -05:00
|
|
|
{
|
|
|
|
|
[JsonConstructor]
|
2025-06-14 13:44:10 -05:00
|
|
|
internal ImageSource() : base(string.Empty, string.Empty)
|
2024-06-27 23:26:53 -05:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="ImageSource"/> class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="mediaType">The media type of the image.</param>
|
|
|
|
|
/// <param name="data">The data of the image.</param>
|
|
|
|
|
/// <exception cref="ArgumentException">Thrown when the media type is invalid.</exception>
|
|
|
|
|
/// <exception cref="ArgumentNullException">Thrown when the media type or data is null.</exception>
|
|
|
|
|
/// <returns>A new instance of the <see cref="ImageSource"/> class.</returns>
|
2025-06-14 13:44:10 -05:00
|
|
|
public ImageSource(string mediaType, string data) : base(mediaType, data)
|
2024-06-27 23:26:53 -05:00
|
|
|
{
|
|
|
|
|
if (ImageType.IsValidImageType(mediaType) is false)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException($"Invalid media type: {mediaType}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MediaType = mediaType;
|
|
|
|
|
Data = data;
|
|
|
|
|
}
|
|
|
|
|
}
|