mirror of
https://github.com/LukeHagar/plexcsharp.git
synced 2025-12-06 04:20:46 +00:00
199 lines
9.3 KiB
C#
199 lines
9.3 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 GetLibrarySectionsAllLibraryOptimizedForStreamingType
|
|
{
|
|
private GetLibrarySectionsAllLibraryOptimizedForStreamingType(string value) { Value = value; }
|
|
|
|
public string Value { get; private set; }
|
|
public static GetLibrarySectionsAllLibraryOptimizedForStreamingType GetLibrarySectionsAllOptimizedForStreamingLibrary1 { get { return new GetLibrarySectionsAllLibraryOptimizedForStreamingType("get-library-sections-all_optimizedForStreaming_Library_1"); } }
|
|
|
|
public static GetLibrarySectionsAllLibraryOptimizedForStreamingType Boolean { get { return new GetLibrarySectionsAllLibraryOptimizedForStreamingType("boolean"); } }
|
|
|
|
public static GetLibrarySectionsAllLibraryOptimizedForStreamingType Null { get { return new GetLibrarySectionsAllLibraryOptimizedForStreamingType("null"); } }
|
|
|
|
public override string ToString() { return Value; }
|
|
public static implicit operator String(GetLibrarySectionsAllLibraryOptimizedForStreamingType v) { return v.Value; }
|
|
public static GetLibrarySectionsAllLibraryOptimizedForStreamingType FromString(string v) {
|
|
switch(v) {
|
|
case "get-library-sections-all_optimizedForStreaming_Library_1": return GetLibrarySectionsAllOptimizedForStreamingLibrary1;
|
|
case "boolean": return Boolean;
|
|
case "null": return Null;
|
|
default: throw new ArgumentException("Invalid value for GetLibrarySectionsAllLibraryOptimizedForStreamingType");
|
|
}
|
|
}
|
|
public override bool Equals(object? obj)
|
|
{
|
|
if (obj == null || GetType() != obj.GetType())
|
|
{
|
|
return false;
|
|
}
|
|
return Value.Equals(((GetLibrarySectionsAllLibraryOptimizedForStreamingType)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(GetLibrarySectionsAllLibraryOptimizedForStreaming.GetLibrarySectionsAllLibraryOptimizedForStreamingConverter))]
|
|
public class GetLibrarySectionsAllLibraryOptimizedForStreaming {
|
|
public GetLibrarySectionsAllLibraryOptimizedForStreaming(GetLibrarySectionsAllLibraryOptimizedForStreamingType type) {
|
|
Type = type;
|
|
}
|
|
|
|
[SpeakeasyMetadata("form:explode=true")]
|
|
public GetLibrarySectionsAllOptimizedForStreamingLibrary1? GetLibrarySectionsAllOptimizedForStreamingLibrary1 { get; set; }
|
|
|
|
[SpeakeasyMetadata("form:explode=true")]
|
|
public bool? Boolean { get; set; }
|
|
|
|
public GetLibrarySectionsAllLibraryOptimizedForStreamingType Type { get; set; }
|
|
|
|
|
|
public static GetLibrarySectionsAllLibraryOptimizedForStreaming CreateGetLibrarySectionsAllOptimizedForStreamingLibrary1(GetLibrarySectionsAllOptimizedForStreamingLibrary1 getLibrarySectionsAllOptimizedForStreamingLibrary1) {
|
|
GetLibrarySectionsAllLibraryOptimizedForStreamingType typ = GetLibrarySectionsAllLibraryOptimizedForStreamingType.GetLibrarySectionsAllOptimizedForStreamingLibrary1;
|
|
|
|
GetLibrarySectionsAllLibraryOptimizedForStreaming res = new GetLibrarySectionsAllLibraryOptimizedForStreaming(typ);
|
|
res.GetLibrarySectionsAllOptimizedForStreamingLibrary1 = getLibrarySectionsAllOptimizedForStreamingLibrary1;
|
|
return res;
|
|
}
|
|
|
|
public static GetLibrarySectionsAllLibraryOptimizedForStreaming CreateBoolean(bool boolean) {
|
|
GetLibrarySectionsAllLibraryOptimizedForStreamingType typ = GetLibrarySectionsAllLibraryOptimizedForStreamingType.Boolean;
|
|
|
|
GetLibrarySectionsAllLibraryOptimizedForStreaming res = new GetLibrarySectionsAllLibraryOptimizedForStreaming(typ);
|
|
res.Boolean = boolean;
|
|
return res;
|
|
}
|
|
|
|
public static GetLibrarySectionsAllLibraryOptimizedForStreaming CreateNull() {
|
|
GetLibrarySectionsAllLibraryOptimizedForStreamingType typ = GetLibrarySectionsAllLibraryOptimizedForStreamingType.Null;
|
|
return new GetLibrarySectionsAllLibraryOptimizedForStreaming(typ);
|
|
}
|
|
|
|
public class GetLibrarySectionsAllLibraryOptimizedForStreamingConverter : JsonConverter
|
|
{
|
|
|
|
public override bool CanConvert(System.Type objectType) => objectType == typeof(GetLibrarySectionsAllLibraryOptimizedForStreaming);
|
|
|
|
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 GetLibrarySectionsAllLibraryOptimizedForStreaming(GetLibrarySectionsAllLibraryOptimizedForStreamingType.GetLibrarySectionsAllOptimizedForStreamingLibrary1)
|
|
{
|
|
GetLibrarySectionsAllOptimizedForStreamingLibrary1 = ResponseBodyDeserializer.DeserializeUndiscriminatedUnionMember<GetLibrarySectionsAllOptimizedForStreamingLibrary1>(json)
|
|
};
|
|
}
|
|
catch (ResponseBodyDeserializer.MissingMemberException)
|
|
{
|
|
fallbackCandidates.Add((typeof(GetLibrarySectionsAllOptimizedForStreamingLibrary1), new GetLibrarySectionsAllLibraryOptimizedForStreaming(GetLibrarySectionsAllLibraryOptimizedForStreamingType.GetLibrarySectionsAllOptimizedForStreamingLibrary1), "GetLibrarySectionsAllOptimizedForStreamingLibrary1"));
|
|
}
|
|
catch (ResponseBodyDeserializer.DeserializationException)
|
|
{
|
|
// try next option
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
|
|
try
|
|
{
|
|
var converted = Convert.ToBoolean(json);
|
|
return new GetLibrarySectionsAllLibraryOptimizedForStreaming(GetLibrarySectionsAllLibraryOptimizedForStreamingType.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;
|
|
}
|
|
GetLibrarySectionsAllLibraryOptimizedForStreaming res = (GetLibrarySectionsAllLibraryOptimizedForStreaming)value;
|
|
if (GetLibrarySectionsAllLibraryOptimizedForStreamingType.FromString(res.Type).Equals(GetLibrarySectionsAllLibraryOptimizedForStreamingType.Null))
|
|
{
|
|
writer.WriteRawValue("null");
|
|
return;
|
|
}
|
|
if (res.GetLibrarySectionsAllOptimizedForStreamingLibrary1 != null)
|
|
{
|
|
writer.WriteRawValue(Utilities.SerializeJSON(res.GetLibrarySectionsAllOptimizedForStreamingLibrary1));
|
|
return;
|
|
}
|
|
if (res.Boolean != null)
|
|
{
|
|
writer.WriteRawValue(Utilities.SerializeJSON(res.Boolean));
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
} |