Renamed library main class and added all endpoint objects to it.
This commit is contained in:
parent
e4d4134ef2
commit
ad7a05ad19
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"cSpell.words": [
|
||||||
|
"Minecraft"
|
||||||
|
]
|
||||||
|
}
|
44
CFCoreAPI/CFCore.cs
Normal file
44
CFCoreAPI/CFCore.cs
Normal file
@ -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 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<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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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<GamesAPI>(() => new GamesAPI(HttpClient));
|
|
||||||
this._filesAPI = new Lazy<FilesAPI>(() => new FilesAPI(HttpClient));
|
|
||||||
}
|
|
||||||
private Lazy<GamesAPI> _gamesAPI;
|
|
||||||
public GamesAPI GamesAPI => this._gamesAPI.Value;
|
|
||||||
private Lazy<FilesAPI> _filesAPI;
|
|
||||||
public FilesAPI FilesAPI => this._filesAPI.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user