mirror of
https://github.com/LukeHagar/plexcsharp.git
synced 2025-12-06 12:37:46 +00:00
ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.391.3
This commit is contained in:
182
LukeHagar/PlexAPI/SDK/Models/Requests/LibrarySectionID.cs
Normal file
182
LukeHagar/PlexAPI/SDK/Models/Requests/LibrarySectionID.cs
Normal file
@@ -0,0 +1,182 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <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.Utils;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
|
||||
|
||||
public class LibrarySectionIDType
|
||||
{
|
||||
private LibrarySectionIDType(string value) { Value = value; }
|
||||
|
||||
public string Value { get; private set; }
|
||||
public static LibrarySectionIDType Integer { get { return new LibrarySectionIDType("integer"); } }
|
||||
|
||||
public static LibrarySectionIDType Str { get { return new LibrarySectionIDType("str"); } }
|
||||
|
||||
public static LibrarySectionIDType Null { get { return new LibrarySectionIDType("null"); } }
|
||||
|
||||
public override string ToString() { return Value; }
|
||||
public static implicit operator String(LibrarySectionIDType v) { return v.Value; }
|
||||
public static LibrarySectionIDType FromString(string v) {
|
||||
switch(v) {
|
||||
case "integer": return Integer;
|
||||
case "str": return Str;
|
||||
case "null": return Null;
|
||||
default: throw new ArgumentException("Invalid value for LibrarySectionIDType");
|
||||
}
|
||||
}
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj == null || GetType() != obj.GetType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return Value.Equals(((LibrarySectionIDType)obj).Value);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Value.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[JsonConverter(typeof(LibrarySectionID.LibrarySectionIDConverter))]
|
||||
public class LibrarySectionID {
|
||||
public LibrarySectionID(LibrarySectionIDType type) {
|
||||
Type = type;
|
||||
}
|
||||
|
||||
[SpeakeasyMetadata("form:explode=true")]
|
||||
public long? Integer { get; set; }
|
||||
|
||||
[SpeakeasyMetadata("form:explode=true")]
|
||||
public string? Str { get; set; }
|
||||
|
||||
public LibrarySectionIDType Type { get; set; }
|
||||
|
||||
|
||||
public static LibrarySectionID CreateInteger(long integer) {
|
||||
LibrarySectionIDType typ = LibrarySectionIDType.Integer;
|
||||
|
||||
LibrarySectionID res = new LibrarySectionID(typ);
|
||||
res.Integer = integer;
|
||||
return res;
|
||||
}
|
||||
|
||||
public static LibrarySectionID CreateStr(string str) {
|
||||
LibrarySectionIDType typ = LibrarySectionIDType.Str;
|
||||
|
||||
LibrarySectionID res = new LibrarySectionID(typ);
|
||||
res.Str = str;
|
||||
return res;
|
||||
}
|
||||
|
||||
public static LibrarySectionID CreateNull() {
|
||||
LibrarySectionIDType typ = LibrarySectionIDType.Null;
|
||||
return new LibrarySectionID(typ);
|
||||
}
|
||||
|
||||
public class LibrarySectionIDConverter : JsonConverter
|
||||
{
|
||||
|
||||
public override bool CanConvert(System.Type objectType) => objectType == typeof(LibrarySectionID);
|
||||
|
||||
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
|
||||
{
|
||||
var converted = Convert.ToInt64(json);
|
||||
return new LibrarySectionID(LibrarySectionIDType.Integer)
|
||||
{
|
||||
Integer = converted
|
||||
};
|
||||
}
|
||||
catch (System.FormatException)
|
||||
{
|
||||
// try next option
|
||||
}
|
||||
|
||||
if (json[0] == '"' && json[^1] == '"'){
|
||||
return new LibrarySectionID(LibrarySectionIDType.Str)
|
||||
{
|
||||
Str = json[1..^1]
|
||||
};
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
LibrarySectionID res = (LibrarySectionID)value;
|
||||
if (LibrarySectionIDType.FromString(res.Type).Equals(LibrarySectionIDType.Null))
|
||||
{
|
||||
writer.WriteRawValue("null");
|
||||
return;
|
||||
}
|
||||
if (res.Integer != null)
|
||||
{
|
||||
writer.WriteRawValue(Utilities.SerializeJSON(res.Integer));
|
||||
return;
|
||||
}
|
||||
if (res.Str != null)
|
||||
{
|
||||
writer.WriteRawValue(Utilities.SerializeJSON(res.Str));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user