From 311026fc3d5f8530f28f1677abcba9d7df484bc1 Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Fri, 20 May 2022 16:48:25 -0500 Subject: [PATCH] Renamed library main class and added all endpoint objects to it. --- .vscode/settings.json | 5 +++++ CFCoreAPI/CFCore.cs | 44 ++++++++++++++++++++++++++++++++++++++++++ CFCoreAPI/CFCoreAPI.cs | 28 --------------------------- 3 files changed, 49 insertions(+), 28 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 CFCoreAPI/CFCore.cs delete mode 100644 CFCoreAPI/CFCoreAPI.cs diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..62c871c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "cSpell.words": [ + "Minecraft" + ] +} \ No newline at end of file diff --git a/CFCoreAPI/CFCore.cs b/CFCoreAPI/CFCore.cs new file mode 100644 index 0000000..80c4cea --- /dev/null +++ b/CFCoreAPI/CFCore.cs @@ -0,0 +1,44 @@ +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(() => new GamesAPI(HttpClient)); + this._categoriesAPI = new Lazy(() => new CategoriesAPI(HttpClient)); + this._modsAPI = new Lazy(() => new ModsAPI(HttpClient)); + this._filesAPI = new Lazy(() => new FilesAPI(HttpClient)); + this._fingerprintAPI = new Lazy(() => new FingerprintsAPI(HttpClient)); + this._minecraftAPI = new Lazy(() => new MinecraftAPI(HttpClient)); + } + private Lazy _gamesAPI; + public GamesAPI Games => this._gamesAPI.Value; + private Lazy _categoriesAPI; + public CategoriesAPI Categories => this._categoriesAPI.Value; + private Lazy _modsAPI; + public ModsAPI Mods => this._modsAPI.Value; + private Lazy _filesAPI; + public FilesAPI Files => this._filesAPI.Value; + private Lazy _fingerprintAPI; + public FingerprintsAPI Fingerprints => this._fingerprintAPI.Value; + private Lazy _minecraftAPI; + public MinecraftAPI Minecraft => this._minecraftAPI.Value; + } + +} \ No newline at end of file diff --git a/CFCoreAPI/CFCoreAPI.cs b/CFCoreAPI/CFCoreAPI.cs deleted file mode 100644 index 93b4173..0000000 --- a/CFCoreAPI/CFCoreAPI.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Net.Http; -using CFCoreAPI.Endpoints.Files; -using CFCoreAPI.Endpoints.Games; - -namespace CFCoreAPI -{ - public class CFCoreAPI - { - private readonly string _apiKey; - public HttpClient HttpClient { get; private set; } - - public CFCoreAPI(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(() => new GamesAPI(HttpClient)); - this._filesAPI = new Lazy(() => new FilesAPI(HttpClient)); - } - private Lazy _gamesAPI; - public GamesAPI GamesAPI => this._gamesAPI.Value; - private Lazy _filesAPI; - public FilesAPI FilesAPI => this._filesAPI.Value; - } - -} \ No newline at end of file