Files
plexcsharp/LukeHagar/PlexAPI/SDK/Models/Requests/GetSearchAllLibrariesOptimizedForStreaming.cs

199 lines
8.8 KiB
C#

//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
//
// Changes to this file may cause incorrect behavior and will be lost when
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable
namespace LukeHagar.PlexAPI.SDK.Models.Requests
{
using LukeHagar.PlexAPI.SDK.Models.Requests;
using LukeHagar.PlexAPI.SDK.Utils;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Reflection;
public class GetSearchAllLibrariesOptimizedForStreamingType
{
private GetSearchAllLibrariesOptimizedForStreamingType(string value) { Value = value; }
public string Value { get; private set; }
public static GetSearchAllLibrariesOptimizedForStreamingType GetSearchAllLibrariesOptimizedForStreaming1 { get { return new GetSearchAllLibrariesOptimizedForStreamingType("get-search-all-libraries_optimizedForStreaming_1"); } }
public static GetSearchAllLibrariesOptimizedForStreamingType Boolean { get { return new GetSearchAllLibrariesOptimizedForStreamingType("boolean"); } }
public static GetSearchAllLibrariesOptimizedForStreamingType Null { get { return new GetSearchAllLibrariesOptimizedForStreamingType("null"); } }
public override string ToString() { return Value; }
public static implicit operator String(GetSearchAllLibrariesOptimizedForStreamingType v) { return v.Value; }
public static GetSearchAllLibrariesOptimizedForStreamingType FromString(string v) {
switch(v) {
case "get-search-all-libraries_optimizedForStreaming_1": return GetSearchAllLibrariesOptimizedForStreaming1;
case "boolean": return Boolean;
case "null": return Null;
default: throw new ArgumentException("Invalid value for GetSearchAllLibrariesOptimizedForStreamingType");
}
}
public override bool Equals(object? obj)
{
if (obj == null || GetType() != obj.GetType())
{
return false;
}
return Value.Equals(((GetSearchAllLibrariesOptimizedForStreamingType)obj).Value);
}
public override int GetHashCode()
{
return Value.GetHashCode();
}
}
/// <summary>
/// Has this media been optimized for streaming. NOTE: This can be 0, 1, false or true
/// </summary>
[JsonConverter(typeof(GetSearchAllLibrariesOptimizedForStreaming.GetSearchAllLibrariesOptimizedForStreamingConverter))]
public class GetSearchAllLibrariesOptimizedForStreaming {
public GetSearchAllLibrariesOptimizedForStreaming(GetSearchAllLibrariesOptimizedForStreamingType type) {
Type = type;
}
[SpeakeasyMetadata("form:explode=true")]
public GetSearchAllLibrariesOptimizedForStreaming1? GetSearchAllLibrariesOptimizedForStreaming1 { get; set; }
[SpeakeasyMetadata("form:explode=true")]
public bool? Boolean { get; set; }
public GetSearchAllLibrariesOptimizedForStreamingType Type { get; set; }
public static GetSearchAllLibrariesOptimizedForStreaming CreateGetSearchAllLibrariesOptimizedForStreaming1(GetSearchAllLibrariesOptimizedForStreaming1 getSearchAllLibrariesOptimizedForStreaming1) {
GetSearchAllLibrariesOptimizedForStreamingType typ = GetSearchAllLibrariesOptimizedForStreamingType.GetSearchAllLibrariesOptimizedForStreaming1;
GetSearchAllLibrariesOptimizedForStreaming res = new GetSearchAllLibrariesOptimizedForStreaming(typ);
res.GetSearchAllLibrariesOptimizedForStreaming1 = getSearchAllLibrariesOptimizedForStreaming1;
return res;
}
public static GetSearchAllLibrariesOptimizedForStreaming CreateBoolean(bool boolean) {
GetSearchAllLibrariesOptimizedForStreamingType typ = GetSearchAllLibrariesOptimizedForStreamingType.Boolean;
GetSearchAllLibrariesOptimizedForStreaming res = new GetSearchAllLibrariesOptimizedForStreaming(typ);
res.Boolean = boolean;
return res;
}
public static GetSearchAllLibrariesOptimizedForStreaming CreateNull() {
GetSearchAllLibrariesOptimizedForStreamingType typ = GetSearchAllLibrariesOptimizedForStreamingType.Null;
return new GetSearchAllLibrariesOptimizedForStreaming(typ);
}
public class GetSearchAllLibrariesOptimizedForStreamingConverter : JsonConverter
{
public override bool CanConvert(System.Type objectType) => objectType == typeof(GetSearchAllLibrariesOptimizedForStreaming);
public override bool CanRead => true;
public override object? ReadJson(JsonReader reader, System.Type objectType, object? existingValue, JsonSerializer serializer)
{
var json = JRaw.Create(reader).ToString();
if (json == "null")
{
return null;
}
var fallbackCandidates = new List<(System.Type, object, string)>();
try
{
return new GetSearchAllLibrariesOptimizedForStreaming(GetSearchAllLibrariesOptimizedForStreamingType.GetSearchAllLibrariesOptimizedForStreaming1)
{
GetSearchAllLibrariesOptimizedForStreaming1 = ResponseBodyDeserializer.DeserializeUndiscriminatedUnionMember<GetSearchAllLibrariesOptimizedForStreaming1>(json)
};
}
catch (ResponseBodyDeserializer.MissingMemberException)
{
fallbackCandidates.Add((typeof(GetSearchAllLibrariesOptimizedForStreaming1), new GetSearchAllLibrariesOptimizedForStreaming(GetSearchAllLibrariesOptimizedForStreamingType.GetSearchAllLibrariesOptimizedForStreaming1), "GetSearchAllLibrariesOptimizedForStreaming1"));
}
catch (ResponseBodyDeserializer.DeserializationException)
{
// try next option
}
catch (Exception)
{
throw;
}
try
{
var converted = Convert.ToBoolean(json);
return new GetSearchAllLibrariesOptimizedForStreaming(GetSearchAllLibrariesOptimizedForStreamingType.Boolean)
{
Boolean = converted
};
}
catch (System.FormatException)
{
// try next option
}
if (fallbackCandidates.Count > 0)
{
fallbackCandidates.Sort((a, b) => ResponseBodyDeserializer.CompareFallbackCandidates(a.Item1, b.Item1, json));
foreach(var (deserializationType, returnObject, propertyName) in fallbackCandidates)
{
try
{
return ResponseBodyDeserializer.DeserializeUndiscriminatedUnionFallback(deserializationType, returnObject, propertyName, json);
}
catch (ResponseBodyDeserializer.DeserializationException)
{
// try next fallback option
}
catch (Exception)
{
throw;
}
}
}
throw new InvalidOperationException("Could not deserialize into any supported types.");
}
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
if (value == null) {
writer.WriteRawValue("null");
return;
}
GetSearchAllLibrariesOptimizedForStreaming res = (GetSearchAllLibrariesOptimizedForStreaming)value;
if (GetSearchAllLibrariesOptimizedForStreamingType.FromString(res.Type).Equals(GetSearchAllLibrariesOptimizedForStreamingType.Null))
{
writer.WriteRawValue("null");
return;
}
if (res.GetSearchAllLibrariesOptimizedForStreaming1 != null)
{
writer.WriteRawValue(Utilities.SerializeJSON(res.GetSearchAllLibrariesOptimizedForStreaming1));
return;
}
if (res.Boolean != null)
{
writer.WriteRawValue(Utilities.SerializeJSON(res.Boolean));
return;
}
}
}
}
}