using System;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Thunderstore-API")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Thunderstore-API")]
[assembly: AssemblyTitle("Thunderstore-API")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace Thunderstore_API
{
[Serializable]
public class Package
{
[JsonProperty("name")]
public string Name;
[JsonProperty("full_name")]
public string FullName;
[JsonProperty("owner")]
public string Owner;
[JsonProperty("package_url")]
public string PackageUrl;
[JsonProperty("donation_link")]
public string DonationLink;
[JsonProperty("date_created")]
public string DateCreated;
[JsonProperty("date_updated")]
public string DateUpdated;
[JsonProperty("uuid4")]
public string Uuid4;
[JsonProperty("rating_score")]
public string RatingScore;
[JsonProperty("is_pinned")]
public string IsPinned;
[JsonProperty("is_deprecated")]
public string IsDeprecated;
[JsonProperty("has_nsfw_content")]
public string HasNsfwContent;
[JsonProperty("categories")]
public string[] Categories;
[JsonProperty("versions")]
public Version[] Versions;
}
[Serializable]
public class Version
{
[JsonProperty("name")]
public string Name;
[JsonProperty("full_name")]
public string FullName;
[JsonProperty("description")]
public string Description;
[JsonProperty("icon")]
public Uri Icon;
[JsonProperty("version_number")]
public string VersionNumber;
[JsonProperty("dependencies")]
public object[] Dependencies;
[JsonProperty("download_url")]
public Uri DownloadUrl;
[JsonProperty("downloads")]
public long Downloads;
[JsonProperty("date_created")]
public DateTimeOffset DateCreated;
[JsonProperty("website_url")]
public Uri WebsiteUrl;
[JsonProperty("is_active")]
public bool IsActive;
[JsonProperty("uuid4")]
public Guid Uuid4;
[JsonProperty("file_size")]
public long FileSize;
}
public static class ThunderstoreAPI
{
public static async Task<Package[]> ReturnThunderstorePackages()
{
using HttpClient httpClient = new HttpClient();
using HttpRequestMessage request = new HttpRequestMessage(new HttpMethod("GET"), "https://thunderstore.io/c/lethal-company/api/v1/package/");
request.Headers.TryAddWithoutValidation("accept", "application/json");
return JsonConvert.DeserializeObject<Package[]>(await (await httpClient.SendAsync(request)).Content.ReadAsStringAsync());
}
public static async Task<Package> ReturnThunderstorePackageByName(string name)
{
string name2 = name;
using HttpClient httpClient = new HttpClient();
using HttpRequestMessage request = new HttpRequestMessage(new HttpMethod("GET"), "https://thunderstore.io/c/lethal-company/api/v1/package/");
request.Headers.TryAddWithoutValidation("accept", "application/json");
Package[] temp = JsonConvert.DeserializeObject<Package[]>(await (await httpClient.SendAsync(request)).Content.ReadAsStringAsync());
return temp.First((Package x) => x.Name == name2);
}
}
}