using System.Text.Json.Serialization;

namespace Olive.Klipy;

internal sealed record KlipyGif(
  string Id,
  string Title,
  Uri ThumbnailGifUrl,
  Uri GifUrl);

internal sealed record KlipySearchResult(
  IReadOnlyList<KlipyGif> Gifs,
  bool HasMore);

internal sealed record KlipySearchResponse(
  [property: JsonPropertyName("result")] bool Result,
  [property: JsonPropertyName("data")] KlipySearchData? Data);

internal sealed record KlipySearchData(
  [property: JsonPropertyName("data")] KlipyItem[]? Items,
  [property: JsonPropertyName("has_next")]
  bool? HasNext);

internal sealed record KlipyItem(
  [property: JsonPropertyName("id")] long? Id,
  [property: JsonPropertyName("slug")] string? Slug,
  [property: JsonPropertyName("title")] string? Title,
  [property: JsonPropertyName("file")] KlipyFile? File);

internal sealed record KlipyFile(
  [property: JsonPropertyName("hd")] KlipyFileSize? Hd,
  [property: JsonPropertyName("md")] KlipyFileSize? Md,
  [property: JsonPropertyName("sm")] KlipyFileSize? Sm);

internal sealed record KlipyFileSize(
  [property: JsonPropertyName("gif")] KlipyMediaFormat? Gif);

internal sealed record KlipyMediaFormat(
  [property: JsonPropertyName("url")] string? Url);

[JsonSerializable(typeof(KlipySearchResponse))]
internal sealed partial class KlipyJsonContext : JsonSerializerContext;
