44 lines
1.9 KiB
C#
44 lines
1.9 KiB
C#
using System.Net.Http;
|
|
using CFCoreAPI.Endpoints.Categories;
|
|
using CFCoreAPI.Endpoints.Files;
|
|
using CFCoreAPI.Endpoints.Fingerprints;
|
|
using CFCoreAPI.Endpoints.Games;
|
|
using CFCoreAPI.Endpoints.Minecraft;
|
|
using CFCoreAPI.Endpoints.Mods;
|
|
|
|
namespace CFCoreAPI
|
|
{
|
|
public class CFCore
|
|
{
|
|
private readonly string _apiKey;
|
|
public HttpClient HttpClient { get; private set; }
|
|
|
|
public CFCore(string key)
|
|
{
|
|
this._apiKey = key;
|
|
this.HttpClient = new HttpClient();
|
|
this.HttpClient.BaseAddress = new Uri("https://api.curseforge.com");
|
|
this.HttpClient.DefaultRequestHeaders.Add("x-api-key", _apiKey);
|
|
|
|
this._gamesAPI = new Lazy<GamesAPI>(() => new GamesAPI(HttpClient));
|
|
this._categoriesAPI = new Lazy<CategoriesAPI>(() => new CategoriesAPI(HttpClient));
|
|
this._modsAPI = new Lazy<ModsAPI>(() => new ModsAPI(HttpClient));
|
|
this._filesAPI = new Lazy<FilesAPI>(() => new FilesAPI(HttpClient));
|
|
this._fingerprintAPI = new Lazy<FingerprintsAPI>(() => new FingerprintsAPI(HttpClient));
|
|
this._minecraftAPI = new Lazy<MinecraftAPI>(() => new MinecraftAPI(HttpClient));
|
|
}
|
|
private Lazy<GamesAPI> _gamesAPI;
|
|
public GamesAPI Games => this._gamesAPI.Value;
|
|
private Lazy<CategoriesAPI> _categoriesAPI;
|
|
public CategoriesAPI Categories => this._categoriesAPI.Value;
|
|
private Lazy<ModsAPI> _modsAPI;
|
|
public ModsAPI Mods => this._modsAPI.Value;
|
|
private Lazy<FilesAPI> _filesAPI;
|
|
public FilesAPI Files => this._filesAPI.Value;
|
|
private Lazy<FingerprintsAPI> _fingerprintAPI;
|
|
public FingerprintsAPI Fingerprints => this._fingerprintAPI.Value;
|
|
private Lazy<MinecraftAPI> _minecraftAPI;
|
|
public MinecraftAPI Minecraft => this._minecraftAPI.Value;
|
|
}
|
|
|
|
} |