From 1ff74426a038dda7586acdeb166c5655d7005443 Mon Sep 17 00:00:00 2001 From: Not Officer Date: Sun, 5 Jul 2020 21:39:02 +0200 Subject: [PATCH] implemented all V2 endpoints + minor refactoring --- src/Fortnite-API.Test/Program.cs | 33 +++ .../Endpoints/V1/StatsV1Endpoints.cs | 70 ++++++ src/Fortnite-API/Endpoints/V1/V1Endpoints.cs | 2 + .../Endpoints/V2/AesV2Endpoints.cs | 33 +++ .../Endpoints/V2/CosmeticsV2Endpoints.cs | 132 +++++++++++ .../Endpoints/V2/CreatorCodeV2Endpoints.cs | 104 +++++++++ .../Endpoints/V2/NewsV2Endpoints.cs | 77 ++++++ .../Endpoints/V2/ShopV2Endpoints.cs | 51 ++++ src/Fortnite-API/Endpoints/V2/V2Endpoints.cs | 22 ++ src/Fortnite-API/Extensions.cs | 73 +++++- src/Fortnite-API/Fortnite-API.csproj | 7 +- src/Fortnite-API/FortniteApi.cs | 3 + src/Fortnite-API/JsonNetSerializer.cs | 8 +- src/Fortnite-API/Objects/AccountData.cs | 67 ++++++ src/Fortnite-API/Objects/ApiResponse.cs | 16 +- src/Fortnite-API/Objects/V1/AesV1.cs | 6 +- src/Fortnite-API/Objects/V1/BrCosmeticV1.cs | 76 +++--- .../Objects/V1/BrCosmeticV1Images.cs | 25 +- .../Objects/V1/BrCosmeticV1Type.cs | 1 + .../Objects/V1/BrCosmeticV1Variant.cs | 6 +- .../Objects/V1/BrCosmeticV1VariantOption.cs | 6 +- src/Fortnite-API/Objects/V1/BrShopV1.cs | 21 +- src/Fortnite-API/Objects/V1/BrShopV1Entry.cs | 20 +- src/Fortnite-API/Objects/V1/BrStatsV2V1.cs | 72 ++++++ .../Objects/V1/BrStatsV2V1AccountType.cs | 9 + .../Objects/V1/BrStatsV2V1BattlePass.cs | 67 ++++++ .../Objects/V1/BrStatsV2V1DuoStats.cs | 86 +++++++ .../Objects/V1/BrStatsV2V1ImagePlatform.cs | 11 + .../Objects/V1/BrStatsV2V1LtmStats.cs | 84 +++++++ .../Objects/V1/BrStatsV2V1OverallStats.cs | 90 +++++++ .../V1/BrStatsV2V1RequestProperties.cs | 11 + .../Objects/V1/BrStatsV2V1SoloStats.cs | 86 +++++++ .../Objects/V1/BrStatsV2V1SquadStats.cs | 86 +++++++ .../Objects/V1/BrStatsV2V1Stats.cs | 71 ++++++ .../Objects/V1/BrStatsV2V1StatsPlatform.cs | 75 ++++++ .../Objects/V1/BrStatsV2V1TimeWindow.cs | 8 + src/Fortnite-API/Objects/V1/CombinedNewsV1.cs | 6 +- src/Fortnite-API/Objects/V1/CreatorCodeV1.cs | 10 +- src/Fortnite-API/Objects/V1/ImageV1Data.cs | 15 +- src/Fortnite-API/Objects/V1/NewsV1.cs | 10 +- src/Fortnite-API/Objects/V1/NewsV1Message.cs | 20 +- src/Fortnite-API/Objects/V1/NewsV1Motd.cs | 18 +- src/Fortnite-API/Objects/V2/AesV2.cs | 76 ++++++ .../Objects/V2/AesV2DynamicKey.cs | 68 ++++++ src/Fortnite-API/Objects/V2/AesV2KeyFormat.cs | 8 + src/Fortnite-API/Objects/V2/BrCosmeticV2.cs | 99 ++++++++ .../Objects/V2/BrCosmeticV2Images.cs | 72 ++++++ .../Objects/V2/BrCosmeticV2Introduction.cs | 66 ++++++ .../Objects/V2/BrCosmeticV2Rarity.cs | 65 ++++++ .../V2/BrCosmeticV2SearchProperties.cs | 219 ++++++++++++++++++ .../Objects/V2/BrCosmeticV2Series.cs | 65 ++++++ .../Objects/V2/BrCosmeticV2Set.cs | 65 ++++++ .../Objects/V2/BrCosmeticV2Type.cs | 65 ++++++ .../Objects/V2/BrCosmeticV2Variant.cs | 69 ++++++ .../Objects/V2/BrCosmeticV2VariantOption.cs | 65 ++++++ src/Fortnite-API/Objects/V2/BrShopV2.cs | 80 +++++++ .../Objects/V2/BrShopV2Combined.cs | 76 ++++++ .../Objects/V2/BrShopV2StoreFront.cs | 70 ++++++ .../Objects/V2/BrShopV2StoreFrontEntry.cs | 84 +++++++ .../V2/BrShopV2StoreFrontEntryBanner.cs | 67 ++++++ .../V2/BrShopV2StoreFrontEntryBundle.cs | 67 ++++++ src/Fortnite-API/Objects/V2/CreatorCodeV2.cs | 73 ++++++ src/Fortnite-API/Objects/V2/NewsV2.cs | 71 ++++++ src/Fortnite-API/Objects/V2/NewsV2Combined.cs | 69 ++++++ src/Fortnite-API/Objects/V2/NewsV2Message.cs | 73 ++++++ src/Fortnite-API/Objects/V2/NewsV2Motd.cs | 78 +++++++ src/Fortnite-API/Optional.cs | 2 +- src/Fortnite-API/Utilities.cs | 2 + 68 files changed, 3377 insertions(+), 131 deletions(-) create mode 100644 src/Fortnite-API/Endpoints/V1/StatsV1Endpoints.cs create mode 100644 src/Fortnite-API/Endpoints/V2/AesV2Endpoints.cs create mode 100644 src/Fortnite-API/Endpoints/V2/CosmeticsV2Endpoints.cs create mode 100644 src/Fortnite-API/Endpoints/V2/CreatorCodeV2Endpoints.cs create mode 100644 src/Fortnite-API/Endpoints/V2/NewsV2Endpoints.cs create mode 100644 src/Fortnite-API/Endpoints/V2/ShopV2Endpoints.cs create mode 100644 src/Fortnite-API/Endpoints/V2/V2Endpoints.cs create mode 100644 src/Fortnite-API/Objects/AccountData.cs create mode 100644 src/Fortnite-API/Objects/V1/BrStatsV2V1.cs create mode 100644 src/Fortnite-API/Objects/V1/BrStatsV2V1AccountType.cs create mode 100644 src/Fortnite-API/Objects/V1/BrStatsV2V1BattlePass.cs create mode 100644 src/Fortnite-API/Objects/V1/BrStatsV2V1DuoStats.cs create mode 100644 src/Fortnite-API/Objects/V1/BrStatsV2V1ImagePlatform.cs create mode 100644 src/Fortnite-API/Objects/V1/BrStatsV2V1LtmStats.cs create mode 100644 src/Fortnite-API/Objects/V1/BrStatsV2V1OverallStats.cs create mode 100644 src/Fortnite-API/Objects/V1/BrStatsV2V1RequestProperties.cs create mode 100644 src/Fortnite-API/Objects/V1/BrStatsV2V1SoloStats.cs create mode 100644 src/Fortnite-API/Objects/V1/BrStatsV2V1SquadStats.cs create mode 100644 src/Fortnite-API/Objects/V1/BrStatsV2V1Stats.cs create mode 100644 src/Fortnite-API/Objects/V1/BrStatsV2V1StatsPlatform.cs create mode 100644 src/Fortnite-API/Objects/V1/BrStatsV2V1TimeWindow.cs create mode 100644 src/Fortnite-API/Objects/V2/AesV2.cs create mode 100644 src/Fortnite-API/Objects/V2/AesV2DynamicKey.cs create mode 100644 src/Fortnite-API/Objects/V2/AesV2KeyFormat.cs create mode 100644 src/Fortnite-API/Objects/V2/BrCosmeticV2.cs create mode 100644 src/Fortnite-API/Objects/V2/BrCosmeticV2Images.cs create mode 100644 src/Fortnite-API/Objects/V2/BrCosmeticV2Introduction.cs create mode 100644 src/Fortnite-API/Objects/V2/BrCosmeticV2Rarity.cs create mode 100644 src/Fortnite-API/Objects/V2/BrCosmeticV2SearchProperties.cs create mode 100644 src/Fortnite-API/Objects/V2/BrCosmeticV2Series.cs create mode 100644 src/Fortnite-API/Objects/V2/BrCosmeticV2Set.cs create mode 100644 src/Fortnite-API/Objects/V2/BrCosmeticV2Type.cs create mode 100644 src/Fortnite-API/Objects/V2/BrCosmeticV2Variant.cs create mode 100644 src/Fortnite-API/Objects/V2/BrCosmeticV2VariantOption.cs create mode 100644 src/Fortnite-API/Objects/V2/BrShopV2.cs create mode 100644 src/Fortnite-API/Objects/V2/BrShopV2Combined.cs create mode 100644 src/Fortnite-API/Objects/V2/BrShopV2StoreFront.cs create mode 100644 src/Fortnite-API/Objects/V2/BrShopV2StoreFrontEntry.cs create mode 100644 src/Fortnite-API/Objects/V2/BrShopV2StoreFrontEntryBanner.cs create mode 100644 src/Fortnite-API/Objects/V2/BrShopV2StoreFrontEntryBundle.cs create mode 100644 src/Fortnite-API/Objects/V2/CreatorCodeV2.cs create mode 100644 src/Fortnite-API/Objects/V2/NewsV2.cs create mode 100644 src/Fortnite-API/Objects/V2/NewsV2Combined.cs create mode 100644 src/Fortnite-API/Objects/V2/NewsV2Message.cs create mode 100644 src/Fortnite-API/Objects/V2/NewsV2Motd.cs diff --git a/src/Fortnite-API.Test/Program.cs b/src/Fortnite-API.Test/Program.cs index 990904c..26a5c4e 100644 --- a/src/Fortnite-API.Test/Program.cs +++ b/src/Fortnite-API.Test/Program.cs @@ -4,6 +4,7 @@ using Fortnite_API; using Fortnite_API.Objects; using Fortnite_API.Objects.V1; +using Fortnite_API.Objects.V2; namespace Fortnite_api.Test { @@ -14,6 +15,38 @@ private static async Task Main() const string apiKey = null; // optional as of now. check https://dash.fortnite-api.com to be sure var api = new FortniteApi(apiKey); + //var cosmeticsV2 = await api.V2.Cosmetics.GetBrAsync(); + var renegadeSearch = await api.V2.Cosmetics.SearchBrAsync(x => + { + x.Name = "enegade raid"; + x.MatchMethod = MatchMethod.Contains; + x.BackendType = "AthenaCharacter"; + }); + + var aesV2 = await api.V2.Aes.GetAsync(); + var aesV2Base64 = await api.V2.Aes.GetAsync(AesV2KeyFormat.Base64); + + var newsV2 = await api.V2.News.GetAsync(); + var newsV2German = await api.V2.News.GetAsync(GameLanguage.DE); + var newsV2Br = await api.V2.News.GetBrAsync(); + + var creatorCodeV2tfue = await api.V2.CreatorCode.GetAsync("tfue239042039480"); + var creatorCodeV2allStw = await api.V2.CreatorCode.SearchAllAsync("stw"); + + var shopV2 = await api.V2.Shop.GetBrAsync(); + var shopV2German = await api.V2.Shop.GetBrAsync(GameLanguage.DE); + var shopV2Combined = await api.V2.Shop.GetBrCombinedAsync(); + + var statsV2V1 = await api.V1.Stats.GetBrV2Async(x => + { + //x.AccountId = "4735ce9132924caf8a5b17789b40f79c"; + x.Name = "ninja"; + x.ImagePlatform = BrStatsV2V1ImagePlatform.All; + }); + + Debugger.Break(); + return; + var aes = await api.V1.Aes.GetAsync(); await Task.Delay(500); var tfueCode = await api.V1.CreatorCode.GetAsync("tfue"); diff --git a/src/Fortnite-API/Endpoints/V1/StatsV1Endpoints.cs b/src/Fortnite-API/Endpoints/V1/StatsV1Endpoints.cs new file mode 100644 index 0000000..0254901 --- /dev/null +++ b/src/Fortnite-API/Endpoints/V1/StatsV1Endpoints.cs @@ -0,0 +1,70 @@ +using System; +using System.Threading; +using System.Threading.Tasks; + +using Fortnite_API.Objects; +using Fortnite_API.Objects.V1; + +using RestSharp; + +namespace Fortnite_API.Endpoints.V1 +{ + public class StatsV1Endpoints : EndpointBase + { + internal StatsV1Endpoints(IRestClient client) : base(client) { } + + [Obsolete("BR V1 stats are no longer available since Epic Games shut down the endpoint.", true)] + public Task GetBrV1Async() + { + return Task.Delay(1); // net452 doesnt have Task.CompletedTask + } + + [Obsolete("BR V1 stats are no longer available since Epic Games shut down the endpoint.", true)] + public void GetBrV1() { } + + public async Task> GetBrV2Async(Action func, CancellationToken token = default) + { + var props = new BrStatsV2V1RequestProperties(); + func(props); + + RestRequest request; + + if (props.AccountId.HasValue) + { + request = new RestRequest($"v1/stats/br/v2/{props.AccountId.Value}", Method.GET); + } + else if (props.Name.HasValue) + { + request = new RestRequest("v1/stats/br/v2", Method.GET); + request.AddQueryParameter("name", props.Name.Value); + + if (props.AccountType.HasValue) + { + request.AddQueryParameter("accountType", props.AccountType.Value.GetString()); + } + } + else + { + throw new ArgumentException("missing accountId or name"); + } + + if (props.TimeWindow.HasValue) + { + request.AddQueryParameter("timeWindow", props.TimeWindow.Value.GetString()); + } + + if (props.ImagePlatform.HasValue) + { + request.AddQueryParameter("image", props.ImagePlatform.Value.GetString()); + } + + var response = await _client.ExecuteAsync>(request, token).ConfigureAwait(false); + return response.Data; + } + + public ApiResponse GetBrV2Id(Action func) + { + return GetBrV2Async(func).GetAwaiter().GetResult(); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Endpoints/V1/V1Endpoints.cs b/src/Fortnite-API/Endpoints/V1/V1Endpoints.cs index 823be5b..03831ae 100644 --- a/src/Fortnite-API/Endpoints/V1/V1Endpoints.cs +++ b/src/Fortnite-API/Endpoints/V1/V1Endpoints.cs @@ -9,6 +9,7 @@ public class V1Endpoints public NewsV1Endpoints News { get; } public CreatorcodeV1Endpoints CreatorCode { get; } public AesV1Endpoints Aes { get; } + public StatsV1Endpoints Stats { get; } internal V1Endpoints(IRestClient client) { @@ -17,6 +18,7 @@ internal V1Endpoints(IRestClient client) News = new NewsV1Endpoints(client); CreatorCode = new CreatorcodeV1Endpoints(client); Aes = new AesV1Endpoints(client); + Stats = new StatsV1Endpoints(client); } } } \ No newline at end of file diff --git a/src/Fortnite-API/Endpoints/V2/AesV2Endpoints.cs b/src/Fortnite-API/Endpoints/V2/AesV2Endpoints.cs new file mode 100644 index 0000000..3255913 --- /dev/null +++ b/src/Fortnite-API/Endpoints/V2/AesV2Endpoints.cs @@ -0,0 +1,33 @@ +using System.Threading; +using System.Threading.Tasks; + +using Fortnite_API.Objects; +using Fortnite_API.Objects.V2; + +using RestSharp; + +namespace Fortnite_API.Endpoints.V2 +{ + public class AesV2Endpoints : EndpointBase + { + internal AesV2Endpoints(IRestClient client) : base(client) { } + + public async Task> GetAsync(AesV2KeyFormat? keyFormat = null, CancellationToken token = default) + { + var request = new RestRequest("v2/aes", Method.GET); + + if (keyFormat.HasValue) + { + request.AddQueryParameter("keyFormat", keyFormat.Value.GetString()); + } + + var response = await _client.ExecuteAsync>(request, token).ConfigureAwait(false); + return response.Data; + } + + public ApiResponse Get(AesV2KeyFormat? keyFormat = null) + { + return GetAsync(keyFormat).GetAwaiter().GetResult(); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Endpoints/V2/CosmeticsV2Endpoints.cs b/src/Fortnite-API/Endpoints/V2/CosmeticsV2Endpoints.cs new file mode 100644 index 0000000..0a6fca4 --- /dev/null +++ b/src/Fortnite-API/Endpoints/V2/CosmeticsV2Endpoints.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +using Fortnite_API.Objects; +using Fortnite_API.Objects.V2; + +using RestSharp; + +namespace Fortnite_API.Endpoints.V2 +{ + public class CosmeticsV2Endpoints : EndpointBase + { + internal CosmeticsV2Endpoints(IRestClient client) : base(client) { } + + public async Task>> GetBrAsync(GameLanguage? language = null, CancellationToken token = default) + { + var request = new RestRequest("v2/cosmetics/br", Method.GET); + + if (language.HasValue) + { + request.AddQueryParameter("language", language.Value.GetLanguageCode()); + } + + var response = await _client.ExecuteAsync>>(request, token).ConfigureAwait(false); + return response.Data; + } + + public ApiResponse> GetBr(GameLanguage? language = null) + { + return GetBrAsync(language).GetAwaiter().GetResult(); + } + + public async Task> GetBrAsync(string cosmeticId, GameLanguage? language = null, CancellationToken token = default) + { + if (cosmeticId == null) + { + throw new ArgumentNullException(nameof(cosmeticId)); + } + + if (cosmeticId.Length == 0) + { + throw new ArgumentOutOfRangeException(nameof(cosmeticId)); + } + + var request = new RestRequest($"v2/cosmetics/br/{cosmeticId}", Method.GET); + + if (language.HasValue) + { + request.AddQueryParameter("language", language.Value.GetLanguageCode()); + } + + var response = await _client.ExecuteAsync>(request, token).ConfigureAwait(false); + return response.Data; + } + + public ApiResponse GetBr(string cosmeticId, GameLanguage? language = null) + { + return GetBrAsync(cosmeticId, language).GetAwaiter().GetResult(); + } + + public async Task>> SearchBrIdsAsync(IEnumerable cosmeticIds, GameLanguage? language = null, CancellationToken token = default) + { + if (cosmeticIds == null) + { + throw new ArgumentNullException(nameof(cosmeticIds)); + } + + var request = new RestRequest("v2/cosmetics/br/search/ids", Method.GET); + var isArrayEmpty = true; + + foreach (var cosmeticId in cosmeticIds) + { + isArrayEmpty = false; + request.AddQueryParameter("id", cosmeticId); + } + + if (isArrayEmpty) + { + throw new ArgumentOutOfRangeException(nameof(cosmeticIds)); + } + + if (language.HasValue) + { + request.AddQueryParameter("language", language.Value.GetLanguageCode()); + } + + var response = await _client.ExecuteAsync>>(request, token).ConfigureAwait(false); + return response.Data; + } + + public ApiResponse> SearchBrIds(IEnumerable cosmeticIds, GameLanguage? language = null) + { + return SearchBrIdsAsync(cosmeticIds, language).GetAwaiter().GetResult(); + } + + public async Task> SearchBrAsync(Action func, CancellationToken token = default) + { + if (func == null) + { + throw new ArgumentNullException(nameof(func)); + } + + var request = new RestRequest("v2/cosmetics/br/search", Method.GET).ApplySearchParameters(func); + var response = await _client.ExecuteAsync>(request, token).ConfigureAwait(false); + return response.Data; + } + + public ApiResponse SearchBr(Action func) + { + return SearchBrAsync(func).GetAwaiter().GetResult(); + } + + public async Task>> SearchAllBrAsync(Action func, CancellationToken token = default) + { + if (func == null) + { + throw new ArgumentNullException(nameof(func)); + } + + var request = new RestRequest("v2/cosmetics/br/search/all", Method.GET).ApplySearchParameters(func); + var response = await _client.ExecuteAsync>>(request, token).ConfigureAwait(false); + return response.Data; + } + + public ApiResponse> SearchAll(Action func) + { + return SearchAllBrAsync(func).GetAwaiter().GetResult(); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Endpoints/V2/CreatorCodeV2Endpoints.cs b/src/Fortnite-API/Endpoints/V2/CreatorCodeV2Endpoints.cs new file mode 100644 index 0000000..2ee48bf --- /dev/null +++ b/src/Fortnite-API/Endpoints/V2/CreatorCodeV2Endpoints.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +using Fortnite_API.Objects; +using Fortnite_API.Objects.V2; + +using RestSharp; + +namespace Fortnite_API.Endpoints.V2 +{ + public class CreatorCodeV2Endpoints : EndpointBase + { + internal CreatorCodeV2Endpoints(IRestClient client) : base(client) { } + + public async Task> GetAsync(string name, CancellationToken token = default) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + if (name.Length == 0) + { + throw new ArgumentOutOfRangeException(nameof(name)); + } + + var request = new RestRequest("v2/creatorcode", Method.GET) + { + Parameters = + { + new Parameter("name", name, ParameterType.QueryString) + } + }; + + var response = await _client.ExecuteAsync>(request, token).ConfigureAwait(false); + return response.Data; + } + + public ApiResponse Get(string name) + { + return GetAsync(name).GetAwaiter().GetResult(); + } + + public async Task> SearchAsync(string name, CancellationToken token = default) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + if (name.Length == 0) + { + throw new ArgumentOutOfRangeException(nameof(name)); + } + + var request = new RestRequest("v2/creatorcode/search", Method.GET) + { + Parameters = + { + new Parameter("name", name, ParameterType.QueryString) + } + }; + + var response = await _client.ExecuteAsync>(request, token).ConfigureAwait(false); + return response.Data; + } + + public ApiResponse Search(string name) + { + return SearchAsync(name).GetAwaiter().GetResult(); + } + + public async Task>> SearchAllAsync(string name, CancellationToken token = default) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + if (name.Length == 0) + { + throw new ArgumentOutOfRangeException(nameof(name)); + } + + var request = new RestRequest("v2/creatorcode/search/all", Method.GET) + { + Parameters = + { + new Parameter("name", name, ParameterType.QueryString) + } + }; + + var response = await _client.ExecuteAsync>>(request, token).ConfigureAwait(false); + return response.Data; + } + + public ApiResponse> SearchAll(string name) + { + return SearchAllAsync(name).GetAwaiter().GetResult(); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Endpoints/V2/NewsV2Endpoints.cs b/src/Fortnite-API/Endpoints/V2/NewsV2Endpoints.cs new file mode 100644 index 0000000..0d284c5 --- /dev/null +++ b/src/Fortnite-API/Endpoints/V2/NewsV2Endpoints.cs @@ -0,0 +1,77 @@ +using System.Threading; +using System.Threading.Tasks; + +using Fortnite_API.Objects; +using Fortnite_API.Objects.V2; + +using RestSharp; + +namespace Fortnite_API.Endpoints.V2 +{ + public class NewsV2Endpoints : EndpointBase + { + internal NewsV2Endpoints(IRestClient client) : base(client) { } + + public async Task> GetAsync(GameLanguage? language = null, CancellationToken token = default) + { + var request = new RestRequest("v2/news", Method.GET); + + if (language.HasValue) + { + request.AddQueryParameter("language", language.Value.GetLanguageCode()); + } + + var response = await _client.ExecuteAsync>(request, token).ConfigureAwait(false); + return response.Data; + } + + public ApiResponse Get(GameLanguage? language = null) + { + return GetAsync(language).GetAwaiter().GetResult(); + } + + private async Task> GetNewsAsync(IRestRequest request, GameLanguage? language, CancellationToken token) + { + if (language.HasValue) + { + request.AddQueryParameter("language", language.Value.GetLanguageCode()); + } + + var response = await _client.ExecuteAsync>(request, token).ConfigureAwait(false); + return response.Data; + } + + public Task> GetBrAsync(GameLanguage? language = null, CancellationToken token = default) + { + var request = new RestRequest("v2/news/br", Method.GET); + return GetNewsAsync(request, language, token); + } + + public ApiResponse GetBr(GameLanguage? language = null) + { + return GetBrAsync(language).GetAwaiter().GetResult(); + } + + public Task> GetStwAsync(GameLanguage? language = null, CancellationToken token = default) + { + var request = new RestRequest("v2/news/stw", Method.GET); + return GetNewsAsync(request, language, token); + } + + public ApiResponse GetStw(GameLanguage? language = null) + { + return GetStwAsync(language).GetAwaiter().GetResult(); + } + + public Task> GetCreativeAsync(GameLanguage? language = null, CancellationToken token = default) + { + var request = new RestRequest("v2/news/creative", Method.GET); + return GetNewsAsync(request, language, token); + } + + public ApiResponse GetCreative(GameLanguage? language = null) + { + return GetCreativeAsync(language).GetAwaiter().GetResult(); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Endpoints/V2/ShopV2Endpoints.cs b/src/Fortnite-API/Endpoints/V2/ShopV2Endpoints.cs new file mode 100644 index 0000000..4dcaaa8 --- /dev/null +++ b/src/Fortnite-API/Endpoints/V2/ShopV2Endpoints.cs @@ -0,0 +1,51 @@ +using System.Threading; +using System.Threading.Tasks; + +using Fortnite_API.Objects; +using Fortnite_API.Objects.V2; + +using RestSharp; + +namespace Fortnite_API.Endpoints.V2 +{ + public class ShopV2Endpoints : EndpointBase + { + internal ShopV2Endpoints(IRestClient client) : base(client) { } + + public async Task> GetBrAsync(GameLanguage? language = null, CancellationToken token = default) + { + var request = new RestRequest("v2/shop/br", Method.GET); + + if (language.HasValue) + { + request.AddQueryParameter("language", language.Value.GetLanguageCode()); + } + + var response = await _client.ExecuteAsync>(request, token).ConfigureAwait(false); + return response.Data; + } + + public ApiResponse GetBr(GameLanguage? language = null) + { + return GetBrAsync(language).GetAwaiter().GetResult(); + } + + public async Task> GetBrCombinedAsync(GameLanguage? language = null, CancellationToken token = default) + { + var request = new RestRequest("v2/shop/br/combined", Method.GET); + + if (language.HasValue) + { + request.AddQueryParameter("language", language.Value.GetLanguageCode()); + } + + var response = await _client.ExecuteAsync>(request, token).ConfigureAwait(false); + return response.Data; + } + + public ApiResponse GetBrCombined(GameLanguage? language = null) + { + return GetBrCombinedAsync(language).GetAwaiter().GetResult(); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Endpoints/V2/V2Endpoints.cs b/src/Fortnite-API/Endpoints/V2/V2Endpoints.cs new file mode 100644 index 0000000..f87480c --- /dev/null +++ b/src/Fortnite-API/Endpoints/V2/V2Endpoints.cs @@ -0,0 +1,22 @@ +using RestSharp; + +namespace Fortnite_API.Endpoints.V2 +{ + public class V2Endpoints + { + public CosmeticsV2Endpoints Cosmetics { get; } + public AesV2Endpoints Aes { get; } + public NewsV2Endpoints News { get; } + public CreatorCodeV2Endpoints CreatorCode { get; } + public ShopV2Endpoints Shop { get; } + + internal V2Endpoints(IRestClient client) + { + Cosmetics = new CosmeticsV2Endpoints(client); + Aes = new AesV2Endpoints(client); + News = new NewsV2Endpoints(client); + CreatorCode = new CreatorCodeV2Endpoints(client); + Shop = new ShopV2Endpoints(client); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Extensions.cs b/src/Fortnite-API/Extensions.cs index 7b5357c..1711e5e 100644 --- a/src/Fortnite-API/Extensions.cs +++ b/src/Fortnite-API/Extensions.cs @@ -3,6 +3,7 @@ using Fortnite_API.Objects; using Fortnite_API.Objects.V1; +using Fortnite_API.Objects.V2; using RestSharp; @@ -49,6 +50,66 @@ public static string GetLanguageCode(this GameLanguage language) } } + public static string GetString(this AesV2KeyFormat keyFormat) + { + switch (keyFormat) + { + case AesV2KeyFormat.Hex: + return "hex"; + case AesV2KeyFormat.Base64: + return "base64"; + default: + throw new ArgumentOutOfRangeException(nameof(keyFormat), keyFormat, null); + } + } + + public static string GetString(this BrStatsV2V1TimeWindow timeWindow) + { + switch (timeWindow) + { + case BrStatsV2V1TimeWindow.Lifetime: + return "lifetime"; + case BrStatsV2V1TimeWindow.Season: + return "season"; + default: + throw new ArgumentOutOfRangeException(nameof(timeWindow), timeWindow, null); + } + } + + public static string GetString(this BrStatsV2V1AccountType accountType) + { + switch (accountType) + { + case BrStatsV2V1AccountType.Epic: + return "epic"; + case BrStatsV2V1AccountType.PSN: + return "psn"; + case BrStatsV2V1AccountType.XBL: + return "xbl"; + default: + throw new ArgumentOutOfRangeException(nameof(accountType), accountType, null); + } + } + + public static string GetString(this BrStatsV2V1ImagePlatform imagePlatform) + { + switch (imagePlatform) + { + case BrStatsV2V1ImagePlatform.None: + return "none"; + case BrStatsV2V1ImagePlatform.All: + return "all"; + case BrStatsV2V1ImagePlatform.KeyboardMouse: + return "keyboardMouse"; + case BrStatsV2V1ImagePlatform.Gamepad: + return "gamepad"; + case BrStatsV2V1ImagePlatform.Touch: + return "touch"; + default: + throw new ArgumentOutOfRangeException(nameof(imagePlatform), imagePlatform, null); + } + } + public static string GetString(this MatchMethod matchMethod) { switch (matchMethod) @@ -92,6 +153,8 @@ public static string GetString(this BrCosmeticV1Type brCosmeticType) return "music"; case BrCosmeticV1Type.Pet: return "pet"; + case BrCosmeticV1Type.PetCarrier: + return "petcarrier"; case BrCosmeticV1Type.Pickaxe: return "pickaxe"; case BrCosmeticV1Type.Spray: @@ -148,7 +211,15 @@ public static string GetString(this bool boolean) return boolean ? "true" : "false"; } - public static RestRequest ApplySearchParameters(this RestRequest request, Action func) + public static IRestRequest ApplySearchParameters(this IRestRequest request, Action func) + { + var searchProperties = new BrCosmeticV2SearchProperties(); + func(searchProperties); + + return searchProperties.AppendParameters(request); + } + + public static IRestRequest ApplySearchParameters(this IRestRequest request, Action func) { var searchProperties = new BrCosmeticV1SearchProperties(); func(searchProperties); diff --git a/src/Fortnite-API/Fortnite-API.csproj b/src/Fortnite-API/Fortnite-API.csproj index a502e42..9980ded 100644 --- a/src/Fortnite-API/Fortnite-API.csproj +++ b/src/Fortnite-API/Fortnite-API.csproj @@ -14,14 +14,15 @@ Fortnite-API, NotOfficer LICENSE - 1.1.0 + 2.0.0 Fortnite-API git Copyright (c) 2019-2020 Fortnite-API.com - 1.1.0.0 - 1.1.0.0 + 2.0.0.0 + 2.0.0.0 logo.png + Implemented all V2 endpoints. diff --git a/src/Fortnite-API/FortniteApi.cs b/src/Fortnite-API/FortniteApi.cs index 6c4f81d..7950237 100644 --- a/src/Fortnite-API/FortniteApi.cs +++ b/src/Fortnite-API/FortniteApi.cs @@ -2,6 +2,7 @@ using System.Reflection; using Fortnite_API.Endpoints.V1; +using Fortnite_API.Endpoints.V2; using RestSharp; @@ -10,6 +11,7 @@ namespace Fortnite_API public class FortniteApi { public V1Endpoints V1 { get; } + public V2Endpoints V2 { get; } public FortniteApi(string apiKey = null) { @@ -25,6 +27,7 @@ public FortniteApi(string apiKey = null) } V1 = new V1Endpoints(client); + V2 = new V2Endpoints(client); } } } \ No newline at end of file diff --git a/src/Fortnite-API/JsonNetSerializer.cs b/src/Fortnite-API/JsonNetSerializer.cs index fa08c87..41c0364 100644 --- a/src/Fortnite-API/JsonNetSerializer.cs +++ b/src/Fortnite-API/JsonNetSerializer.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; using RestSharp; using RestSharp.Serialization; @@ -7,6 +8,11 @@ namespace Fortnite_API { internal class JsonNetSerializer : IRestSerializer { + private static readonly JsonSerializerSettings _serializerSettings = new JsonSerializerSettings + { + ContractResolver = new CamelCasePropertyNamesContractResolver() + }; + public string Serialize(object obj) { return JsonConvert.SerializeObject(obj); @@ -19,7 +25,7 @@ public string Serialize(Parameter parameter) public T Deserialize(IRestResponse response) { - return JsonConvert.DeserializeObject(response.Content); + return JsonConvert.DeserializeObject(response.Content, _serializerSettings); } public string[] SupportedContentTypes { get; } = diff --git a/src/Fortnite-API/Objects/AccountData.cs b/src/Fortnite-API/Objects/AccountData.cs new file mode 100644 index 0000000..443e066 --- /dev/null +++ b/src/Fortnite-API/Objects/AccountData.cs @@ -0,0 +1,67 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects +{ + [DebuggerDisplay("{" + nameof(Name) + "}")] + public class AccountData : IEquatable + { + [J] public string Id { get; set; } + [J] public string Name { get; set; } + + public bool Equals(AccountData other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Id == other.Id && Name == other.Name; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((AccountData)obj); + } + + public override int GetHashCode() + { + unchecked + { + return Id.GetHashCode() * 397 ^ Name.GetHashCode(); + } + } + + public static bool operator ==(AccountData left, AccountData right) + { + return Equals(left, right); + } + + public static bool operator !=(AccountData left, AccountData right) + { + return !Equals(left, right); + } + } +} diff --git a/src/Fortnite-API/Objects/ApiResponse.cs b/src/Fortnite-API/Objects/ApiResponse.cs index 3e087c4..876e145 100644 --- a/src/Fortnite-API/Objects/ApiResponse.cs +++ b/src/Fortnite-API/Objects/ApiResponse.cs @@ -1,16 +1,20 @@ -using I = Newtonsoft.Json.JsonIgnoreAttribute; +using System.Diagnostics; + using J = Newtonsoft.Json.JsonPropertyAttribute; using N = Newtonsoft.Json.NullValueHandling; namespace Fortnite_API.Objects { + [DebuggerDisplay("{" + nameof(DebuggerDisplay) + "}")] public class ApiResponse { - [J("status")] public int Status { get; private set; } - [J("data", NullValueHandling = N.Ignore)] public T Data { get; private set; } - [J("error", NullValueHandling = N.Ignore)] public string Error { get; private set; } + [J] public int Status { get; private set; } + [J(NullValueHandling = N.Ignore)] public T Data { get; private set; } + [J(NullValueHandling = N.Ignore)] public string Error { get; private set; } + + public bool IsSuccess => Status == 200; + public bool HasError => Error != null; - [I] public bool IsSuccess => Status == 200; - [I] public bool HasError => Error != null; + private object DebuggerDisplay => IsSuccess ? Data : (object)$"Error: {Status} | {Error}"; } } \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V1/AesV1.cs b/src/Fortnite-API/Objects/V1/AesV1.cs index 63678ff..6e89acb 100644 --- a/src/Fortnite-API/Objects/V1/AesV1.cs +++ b/src/Fortnite-API/Objects/V1/AesV1.cs @@ -6,9 +6,9 @@ namespace Fortnite_API.Objects.V1 { public class AesV1 : IEquatable { - [J("aes")] public string Aes { get; private set; } - [J("build")] public string Build { get; private set; } - [J("lastUpdate")] public DateTime LastUpdate { get; private set; } + [J] public string Aes { get; private set; } + [J] public string Build { get; private set; } + [J] public DateTime LastUpdate { get; private set; } public bool Equals(AesV1 other) { diff --git a/src/Fortnite-API/Objects/V1/BrCosmeticV1.cs b/src/Fortnite-API/Objects/V1/BrCosmeticV1.cs index d358972..91d8660 100644 --- a/src/Fortnite-API/Objects/V1/BrCosmeticV1.cs +++ b/src/Fortnite-API/Objects/V1/BrCosmeticV1.cs @@ -8,7 +8,7 @@ namespace Fortnite_API.Objects.V1 { public class BrCosmeticV1 : IEquatable { - [J("id")] public string Id { get; private set; } + [J] public string Id { get; private set; } private string _typeString; [J("type")] public string TypeString @@ -16,9 +16,9 @@ public class BrCosmeticV1 : IEquatable get => _typeString; private set => Type = Utilities.GetBrCosmeticV1Type(_typeString = value); } - public BrCosmeticV1Type Type { get; private set; } = BrCosmeticV1Type.Unknown; + [I] public BrCosmeticV1Type Type { get; private set; } = BrCosmeticV1Type.Unknown; - [J("backendType")] public string BackendType { get; private set; } + [J] public string BackendType { get; private set; } private string _rarityString; [J("rarity")] public string RarityString @@ -26,37 +26,42 @@ public class BrCosmeticV1 : IEquatable get => _rarityString; private set => Rarity = Utilities.GetBrCosmeticV1Rarity(_rarityString = value); } - public BrCosmeticV1Rarity Rarity { get; private set; } = BrCosmeticV1Rarity.Unknown; - - [J("displayRarity")] public string DisplayRarity { get; private set; } - [J("backendRarity")] public string BackendRarity { get; private set; } - [J("name")] public string Name { get; private set; } - [J("shortDescription")] public string ShortDescription { get; private set; } - [J("description")] public string Description { get; private set; } - [J("set")] public string Set { get; private set; } - [J("setText")] public string SetText { get; private set; } - [J("series")] public string Series { get; private set; } - [J("backendSeries")] public string BackendSeries { get; private set; } - [J("images")] public BrCosmeticV1Images Images { get; private set; } - [J("variants")] public List Variants { get; private set; } - [J("gameplayTags")] public List GameplayTags { get; private set; } - [J("displayAssetPath")] public string DisplayAssetPath { get; private set; } - [J("definition")] public string Definition { get; private set; } - [J("requiredItemId")] public string RequiredItemId { get; private set; } - [J("builtInEmoteId")] public string BuiltInEmoteId { get; private set; } - [J("path")] public string Path { get; private set; } - [J("lastUpdate")] public DateTime LastUpdate { get; private set; } - [J("added")] public DateTime Added { get; private set; } - - [I] public bool HasSet => Set != null; - [I] public bool HasSetText => SetText != null; - [I] public bool HasSeries => Series != null; - [I] public bool HasDisplayAssetPath => DisplayAssetPath != null; - [I] public bool HasDefinition => Definition != null; - [I] public bool HasRequiredItemId => RequiredItemId != null; - [I] public bool HasBuiltInEmoteId => BuiltInEmoteId != null; - [I] public bool HasVariants => Variants != null && Variants.Count != 0; - [I] public bool HasGameplayTags => GameplayTags != null && GameplayTags.Count != 0; + [I] public BrCosmeticV1Rarity Rarity { get; private set; } = BrCosmeticV1Rarity.Unknown; + + [J] public string DisplayRarity { get; private set; } + [J] public string BackendRarity { get; private set; } + [J] public string Name { get; private set; } + [J] public string ShortDescription { get; private set; } + [J] public string Description { get; private set; } + [J] public string Set { get; private set; } + [J] public string SetText { get; private set; } + [J] public string Series { get; private set; } + [J] public string BackendSeries { get; private set; } + [J] public BrCosmeticV1Images Images { get; private set; } + [J] public List Variants { get; private set; } + [J] public List GameplayTags { get; private set; } + [J] public string DisplayAssetPath { get; private set; } + [J] public string Definition { get; private set; } + [Obsolete("This property will always return null.")] + public string RequiredItemId { get; } = null; + [Obsolete("This property will always return null.")] + public string BuiltInEmoteId { get; } = null; + [J] public string Path { get; private set; } + [Obsolete("This property will always return the same date as the 'Added' property.")] + [J] public DateTime LastUpdate { get; private set; } + [J] public DateTime Added { get; private set; } + + public bool HasSet => Set != null; + public bool HasSetText => SetText != null; + public bool HasSeries => Series != null; + public bool HasDisplayAssetPath => DisplayAssetPath != null; + public bool HasDefinition => Definition != null; + [Obsolete("This property will always return false.")] + public bool HasRequiredItemId { get; } = false; + [Obsolete("This property will always return false.")] + public bool HasBuiltInEmoteId { get; } = false; + public bool HasVariants => Variants != null && Variants.Count != 0; + public bool HasGameplayTags => GameplayTags != null && GameplayTags.Count != 0; public bool HasGameplayTag(string gameplayTag) { @@ -145,7 +150,7 @@ public bool Equals(BrCosmeticV1 other) return true; } - return Id == other.Id && Path == other.Path && LastUpdate.Equals(other.LastUpdate) && Added.Equals(other.Added); + return Id == other.Id && Path == other.Path && Added.Equals(other.Added); } public override bool Equals(object obj) @@ -174,7 +179,6 @@ public override int GetHashCode() { var hashCode = Id != null ? Id.GetHashCode() : 0; hashCode = hashCode * 397 ^ (Path != null ? Path.GetHashCode() : 0); - hashCode = hashCode * 397 ^ LastUpdate.GetHashCode(); hashCode = hashCode * 397 ^ Added.GetHashCode(); return hashCode; } diff --git a/src/Fortnite-API/Objects/V1/BrCosmeticV1Images.cs b/src/Fortnite-API/Objects/V1/BrCosmeticV1Images.cs index efd3d8b..a888479 100644 --- a/src/Fortnite-API/Objects/V1/BrCosmeticV1Images.cs +++ b/src/Fortnite-API/Objects/V1/BrCosmeticV1Images.cs @@ -1,25 +1,24 @@ using System; -using I = Newtonsoft.Json.JsonIgnoreAttribute; using J = Newtonsoft.Json.JsonPropertyAttribute; namespace Fortnite_API.Objects.V1 { public class BrCosmeticV1Images : IEquatable { - [J("smallIcon")] public ImageV1Data SmallIcon { get; private set; } - [J("icon")] public ImageV1Data Icon { get; private set; } - [J("featured")] public ImageV1Data Featured { get; private set; } - [J("background")] public ImageV1Data Background { get; private set; } - [J("coverArt")] public ImageV1Data CoverArt { get; private set; } - [J("decal")] public ImageV1Data Decal { get; private set; } + [J] public ImageV1Data SmallIcon { get; private set; } + [J] public ImageV1Data Icon { get; private set; } + [J] public ImageV1Data Featured { get; private set; } + [J] public ImageV1Data Background { get; private set; } + [J] public ImageV1Data CoverArt { get; private set; } + [J] public ImageV1Data Decal { get; private set; } - [I] public bool HasSmallIcon => SmallIcon != null; - [I] public bool HasIcon => Icon != null; - [I] public bool HasFeatured => Featured != null; - [I] public bool HasBackground => Background != null; - [I] public bool HasCoverArt => CoverArt != null; - [I] public bool HasDecal => Decal != null; + public bool HasSmallIcon => SmallIcon != null; + public bool HasIcon => Icon != null; + public bool HasFeatured => Featured != null; + public bool HasBackground => Background != null; + public bool HasCoverArt => CoverArt != null; + public bool HasDecal => Decal != null; public bool Equals(BrCosmeticV1Images other) { diff --git a/src/Fortnite-API/Objects/V1/BrCosmeticV1Type.cs b/src/Fortnite-API/Objects/V1/BrCosmeticV1Type.cs index 416a3bf..32bcfed 100644 --- a/src/Fortnite-API/Objects/V1/BrCosmeticV1Type.cs +++ b/src/Fortnite-API/Objects/V1/BrCosmeticV1Type.cs @@ -13,6 +13,7 @@ public enum BrCosmeticV1Type LoadingScreen, Music, Pet, + PetCarrier, Pickaxe, Shout, Spray, diff --git a/src/Fortnite-API/Objects/V1/BrCosmeticV1Variant.cs b/src/Fortnite-API/Objects/V1/BrCosmeticV1Variant.cs index aa868f2..3dcdb9c 100644 --- a/src/Fortnite-API/Objects/V1/BrCosmeticV1Variant.cs +++ b/src/Fortnite-API/Objects/V1/BrCosmeticV1Variant.cs @@ -7,9 +7,9 @@ namespace Fortnite_API.Objects.V1 { public class BrCosmeticV1Variant : IEquatable { - [J("channel")] public string Channel { get; private set; } - [J("type")] public string Type { get; private set; } - [J("options")] public List Options { get; private set; } + [J] public string Channel { get; private set; } + [J] public string Type { get; private set; } + [J] public List Options { get; private set; } public bool TryGetVariantOption(string optionName, out BrCosmeticV1VariantOption outOption) { diff --git a/src/Fortnite-API/Objects/V1/BrCosmeticV1VariantOption.cs b/src/Fortnite-API/Objects/V1/BrCosmeticV1VariantOption.cs index 7206570..ecbaedc 100644 --- a/src/Fortnite-API/Objects/V1/BrCosmeticV1VariantOption.cs +++ b/src/Fortnite-API/Objects/V1/BrCosmeticV1VariantOption.cs @@ -6,9 +6,9 @@ namespace Fortnite_API.Objects.V1 { public class BrCosmeticV1VariantOption : IEquatable { - [J("tag")] public string Tag { get; private set; } - [J("name")] public string Name { get; private set; } - [J("image")] public ImageV1Data Image { get; private set; } + [J] public string Tag { get; private set; } + [J] public string Name { get; private set; } + [J] public ImageV1Data Image { get; private set; } public bool Equals(BrCosmeticV1VariantOption other) { diff --git a/src/Fortnite-API/Objects/V1/BrShopV1.cs b/src/Fortnite-API/Objects/V1/BrShopV1.cs index 29bf263..ef6b178 100644 --- a/src/Fortnite-API/Objects/V1/BrShopV1.cs +++ b/src/Fortnite-API/Objects/V1/BrShopV1.cs @@ -1,24 +1,23 @@ using System; using System.Collections.Generic; -using I = Newtonsoft.Json.JsonIgnoreAttribute; using J = Newtonsoft.Json.JsonPropertyAttribute; namespace Fortnite_API.Objects.V1 { public class BrShopV1 : IEquatable { - [J("hash")] public string Hash { get; private set; } - [J("date")] public DateTime Date { get; private set; } - [J("featured")] public List Featured { get; private set; } - [J("daily")] public List Daily { get; private set; } - [J("votes")] public List Votes { get; private set; } - [J("voteWinners")] public List VoteWinners { get; private set; } + [J] public string Hash { get; private set; } + [J] public DateTime Date { get; private set; } + [J] public List Featured { get; private set; } + [J] public List Daily { get; private set; } + [J] public List Votes { get; private set; } + [J] public List VoteWinners { get; private set; } - [I] public bool HasFeaturedEntries => Featured != null && Featured.Count > 0; - [I] public bool HasDailyEntries => Daily != null && Daily.Count > 0; - [I] public bool HasVoteEntries => Votes != null && Votes.Count > 0; - [I] public bool HasVoteWinnerEntries => VoteWinners != null && VoteWinners.Count > 0; + public bool HasFeaturedEntries => Featured != null && Featured.Count > 0; + public bool HasDailyEntries => Daily != null && Daily.Count > 0; + public bool HasVoteEntries => Votes != null && Votes.Count > 0; + public bool HasVoteWinnerEntries => VoteWinners != null && VoteWinners.Count > 0; public bool Equals(BrShopV1 other) { diff --git a/src/Fortnite-API/Objects/V1/BrShopV1Entry.cs b/src/Fortnite-API/Objects/V1/BrShopV1Entry.cs index a50defd..09b5603 100644 --- a/src/Fortnite-API/Objects/V1/BrShopV1Entry.cs +++ b/src/Fortnite-API/Objects/V1/BrShopV1Entry.cs @@ -6,15 +6,15 @@ namespace Fortnite_API.Objects.V1 { public class BrShopV1Entry { - [J("regularPrice")] public int RegularPrice { get; private set; } - [J("finalPrice")] public int FinalPrice { get; private set; } - [J("isBundle")] public bool IsBundle { get; private set; } - [J("isSpecial")] public bool IsSpecial { get; private set; } - [J("giftable")] public bool Giftable { get; private set; } - [J("refundable")] public bool Refundable { get; private set; } - [J("panel")] public int Panel { get; private set; } - [J("sortPriority")] public int SortPriority { get; private set; } - [J("banner")] public string Banner { get; private set; } - [J("items")] public List Items { get; private set; } + [J] public int RegularPrice { get; private set; } + [J] public int FinalPrice { get; private set; } + [J] public bool IsBundle { get; private set; } + [J] public bool IsSpecial { get; private set; } + [J] public bool Giftable { get; private set; } + [J] public bool Refundable { get; private set; } + [J] public int Panel { get; private set; } + [J] public int SortPriority { get; private set; } + [J] public string Banner { get; private set; } + [J] public List Items { get; private set; } } } \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V1/BrStatsV2V1.cs b/src/Fortnite-API/Objects/V1/BrStatsV2V1.cs new file mode 100644 index 0000000..6efd5a2 --- /dev/null +++ b/src/Fortnite-API/Objects/V1/BrStatsV2V1.cs @@ -0,0 +1,72 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V1 +{ + [DebuggerDisplay("{" + nameof(Account) + "}")] + public class BrStatsV2V1 : IEquatable + { + [J] public AccountData Account { get; private set; } + [J] public BrStatsV2V1BattlePass BattlePass { get; private set; } + [J] public Uri Image { get; private set; } + [J] public BrStatsV2V1Stats Stats { get; private set; } + + public bool Equals(BrStatsV2V1 other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Account.Equals(other.Account) && BattlePass.Equals(other.BattlePass) && Stats.Equals(other.Stats); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != this.GetType()) + { + return false; + } + + return Equals((BrStatsV2V1)obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Account.GetHashCode(); + hashCode = hashCode * 397 ^ BattlePass.GetHashCode(); + hashCode = hashCode * 397 ^ Stats.GetHashCode(); + return hashCode; + } + } + + public static bool operator ==(BrStatsV2V1 left, BrStatsV2V1 right) + { + return Equals(left, right); + } + + public static bool operator !=(BrStatsV2V1 left, BrStatsV2V1 right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V1/BrStatsV2V1AccountType.cs b/src/Fortnite-API/Objects/V1/BrStatsV2V1AccountType.cs new file mode 100644 index 0000000..32a9864 --- /dev/null +++ b/src/Fortnite-API/Objects/V1/BrStatsV2V1AccountType.cs @@ -0,0 +1,9 @@ +namespace Fortnite_API.Objects +{ + public enum BrStatsV2V1AccountType + { + Epic, + PSN, + XBL + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V1/BrStatsV2V1BattlePass.cs b/src/Fortnite-API/Objects/V1/BrStatsV2V1BattlePass.cs new file mode 100644 index 0000000..e7d3679 --- /dev/null +++ b/src/Fortnite-API/Objects/V1/BrStatsV2V1BattlePass.cs @@ -0,0 +1,67 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V1 +{ + [DebuggerDisplay("{" + nameof(Level) + "}")] + public class BrStatsV2V1BattlePass : IEquatable + { + [J] public int Level { get; private set; } + [J] public int Progress { get; private set; } + + public bool Equals(BrStatsV2V1BattlePass other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Level == other.Level && Progress == other.Progress; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrStatsV2V1BattlePass)obj); + } + + public override int GetHashCode() + { + unchecked + { + return Level * 397 ^ Progress; + } + } + + public static bool operator ==(BrStatsV2V1BattlePass left, BrStatsV2V1BattlePass right) + { + return Equals(left, right); + } + + public static bool operator !=(BrStatsV2V1BattlePass left, BrStatsV2V1BattlePass right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V1/BrStatsV2V1DuoStats.cs b/src/Fortnite-API/Objects/V1/BrStatsV2V1DuoStats.cs new file mode 100644 index 0000000..a862505 --- /dev/null +++ b/src/Fortnite-API/Objects/V1/BrStatsV2V1DuoStats.cs @@ -0,0 +1,86 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V1 +{ + [DebuggerDisplay("{" + nameof(Score) + "}")] + public class BrStatsV2V1DuoStats : IEquatable + { + [J] public long Score { get; private set; } + [J] public double ScorePerMin { get; private set; } + [J] public double ScorePerMatch { get; private set; } + [J] public long Wins { get; private set; } + [J] public long Top5 { get; private set; } + [J] public long Top12 { get; private set; } + [J] public long Kills { get; private set; } + [J] public double KillsPerMin { get; private set; } + [J] public double KillsPerMatch { get; private set; } + [J] public long Deaths { get; private set; } + [J] public double Kd { get; private set; } + [J] public long Matches { get; private set; } + [J] public double WinRate { get; private set; } + [J] public long MinutesPlayed { get; private set; } + [J] public long PlayersOutlived { get; private set; } + [J] public DateTime LastModified { get; private set; } + + public bool Equals(BrStatsV2V1DuoStats other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Score == other.Score && Wins == other.Wins && Kills == other.Kills && Matches == other.Matches && LastModified.Equals(other.LastModified); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrStatsV2V1DuoStats)obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Score.GetHashCode(); + hashCode = hashCode * 397 ^ Wins.GetHashCode(); + hashCode = hashCode * 397 ^ Kills.GetHashCode(); + hashCode = hashCode * 397 ^ Matches.GetHashCode(); + hashCode = hashCode * 397 ^ LastModified.GetHashCode(); + return hashCode; + } + } + + public static bool operator ==(BrStatsV2V1DuoStats left, BrStatsV2V1DuoStats right) + { + return Equals(left, right); + } + + public static bool operator !=(BrStatsV2V1DuoStats left, BrStatsV2V1DuoStats right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V1/BrStatsV2V1ImagePlatform.cs b/src/Fortnite-API/Objects/V1/BrStatsV2V1ImagePlatform.cs new file mode 100644 index 0000000..4d66c74 --- /dev/null +++ b/src/Fortnite-API/Objects/V1/BrStatsV2V1ImagePlatform.cs @@ -0,0 +1,11 @@ +namespace Fortnite_API.Objects.V1 +{ + public enum BrStatsV2V1ImagePlatform + { + None, + All, + KeyboardMouse, + Gamepad, + Touch + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V1/BrStatsV2V1LtmStats.cs b/src/Fortnite-API/Objects/V1/BrStatsV2V1LtmStats.cs new file mode 100644 index 0000000..494e6c7 --- /dev/null +++ b/src/Fortnite-API/Objects/V1/BrStatsV2V1LtmStats.cs @@ -0,0 +1,84 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V1 +{ + [DebuggerDisplay("{" + nameof(Score) + "}")] + public class BrStatsV2V1LtmStats : IEquatable + { + [J] public long Score { get; private set; } + [J] public double ScorePerMin { get; private set; } + [J] public double ScorePerMatch { get; private set; } + [J] public long Wins { get; private set; } + [J] public long Kills { get; private set; } + [J] public double KillsPerMin { get; private set; } + [J] public double KillsPerMatch { get; private set; } + [J] public long Deaths { get; private set; } + [J] public double Kd { get; private set; } + [J] public long Matches { get; private set; } + [J] public double WinRate { get; private set; } + [J] public long MinutesPlayed { get; private set; } + [J] public long PlayersOutlived { get; private set; } + [J] public DateTime LastModified { get; private set; } + + public bool Equals(BrStatsV2V1LtmStats other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Score == other.Score && Wins == other.Wins && Kills == other.Kills && Matches == other.Matches && LastModified.Equals(other.LastModified); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrStatsV2V1LtmStats)obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Score.GetHashCode(); + hashCode = hashCode * 397 ^ Wins.GetHashCode(); + hashCode = hashCode * 397 ^ Kills.GetHashCode(); + hashCode = hashCode * 397 ^ Matches.GetHashCode(); + hashCode = hashCode * 397 ^ LastModified.GetHashCode(); + return hashCode; + } + } + + public static bool operator ==(BrStatsV2V1LtmStats left, BrStatsV2V1LtmStats right) + { + return Equals(left, right); + } + + public static bool operator !=(BrStatsV2V1LtmStats left, BrStatsV2V1LtmStats right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V1/BrStatsV2V1OverallStats.cs b/src/Fortnite-API/Objects/V1/BrStatsV2V1OverallStats.cs new file mode 100644 index 0000000..c35059e --- /dev/null +++ b/src/Fortnite-API/Objects/V1/BrStatsV2V1OverallStats.cs @@ -0,0 +1,90 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V1 +{ + [DebuggerDisplay("{" + nameof(Score) + "}")] + public class BrStatsV2V1OverallStats : IEquatable + { + [J] public long Score { get; private set; } + [J] public double ScorePerMin { get; private set; } + [J] public double ScorePerMatch { get; private set; } + [J] public long Wins { get; private set; } + [J] public long Top3 { get; private set; } + [J] public long Top5 { get; private set; } + [J] public long Top6 { get; private set; } + [J] public long Top10 { get; private set; } + [J] public long Top12 { get; private set; } + [J] public long Top25 { get; private set; } + [J] public long Kills { get; private set; } + [J] public double KillsPerMin { get; private set; } + [J] public double KillsPerMatch { get; private set; } + [J] public long Deaths { get; private set; } + [J] public double Kd { get; private set; } + [J] public long Matches { get; private set; } + [J] public double WinRate { get; private set; } + [J] public long MinutesPlayed { get; private set; } + [J] public long PlayersOutlived { get; private set; } + [J] public DateTime LastModified { get; private set; } + + public bool Equals(BrStatsV2V1OverallStats other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Score == other.Score && Wins == other.Wins && Kills == other.Kills && Matches == other.Matches && LastModified.Equals(other.LastModified); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrStatsV2V1OverallStats)obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Score.GetHashCode(); + hashCode = hashCode * 397 ^ Wins.GetHashCode(); + hashCode = hashCode * 397 ^ Kills.GetHashCode(); + hashCode = hashCode * 397 ^ Matches.GetHashCode(); + hashCode = hashCode * 397 ^ LastModified.GetHashCode(); + return hashCode; + } + } + + public static bool operator ==(BrStatsV2V1OverallStats left, BrStatsV2V1OverallStats right) + { + return Equals(left, right); + } + + public static bool operator !=(BrStatsV2V1OverallStats left, BrStatsV2V1OverallStats right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V1/BrStatsV2V1RequestProperties.cs b/src/Fortnite-API/Objects/V1/BrStatsV2V1RequestProperties.cs new file mode 100644 index 0000000..6d7a997 --- /dev/null +++ b/src/Fortnite-API/Objects/V1/BrStatsV2V1RequestProperties.cs @@ -0,0 +1,11 @@ +namespace Fortnite_API.Objects.V1 +{ + public class BrStatsV2V1RequestProperties + { + public Optional Name { get; set; } + public Optional AccountType { get; set; } + public Optional AccountId { get; set; } + public Optional TimeWindow { get; set; } + public Optional ImagePlatform { get; set; } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V1/BrStatsV2V1SoloStats.cs b/src/Fortnite-API/Objects/V1/BrStatsV2V1SoloStats.cs new file mode 100644 index 0000000..408c5b7 --- /dev/null +++ b/src/Fortnite-API/Objects/V1/BrStatsV2V1SoloStats.cs @@ -0,0 +1,86 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V1 +{ + [DebuggerDisplay("{" + nameof(Score) + "}")] + public class BrStatsV2V1SoloStats : IEquatable + { + [J] public long Score { get; private set; } + [J] public double ScorePerMin { get; private set; } + [J] public double ScorePerMatch { get; private set; } + [J] public long Wins { get; private set; } + [J] public long Top10 { get; private set; } + [J] public long Top25 { get; private set; } + [J] public long Kills { get; private set; } + [J] public double KillsPerMin { get; private set; } + [J] public double KillsPerMatch { get; private set; } + [J] public long Deaths { get; private set; } + [J] public double Kd { get; private set; } + [J] public long Matches { get; private set; } + [J] public double WinRate { get; private set; } + [J] public long MinutesPlayed { get; private set; } + [J] public long PlayersOutlived { get; private set; } + [J] public DateTime LastModified { get; private set; } + + public bool Equals(BrStatsV2V1SoloStats other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Score == other.Score && Wins == other.Wins && Kills == other.Kills && Matches == other.Matches && LastModified.Equals(other.LastModified); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrStatsV2V1SoloStats)obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Score.GetHashCode(); + hashCode = hashCode * 397 ^ Wins.GetHashCode(); + hashCode = hashCode * 397 ^ Kills.GetHashCode(); + hashCode = hashCode * 397 ^ Matches.GetHashCode(); + hashCode = hashCode * 397 ^ LastModified.GetHashCode(); + return hashCode; + } + } + + public static bool operator ==(BrStatsV2V1SoloStats left, BrStatsV2V1SoloStats right) + { + return Equals(left, right); + } + + public static bool operator !=(BrStatsV2V1SoloStats left, BrStatsV2V1SoloStats right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V1/BrStatsV2V1SquadStats.cs b/src/Fortnite-API/Objects/V1/BrStatsV2V1SquadStats.cs new file mode 100644 index 0000000..bd6b60b --- /dev/null +++ b/src/Fortnite-API/Objects/V1/BrStatsV2V1SquadStats.cs @@ -0,0 +1,86 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V1 +{ + [DebuggerDisplay("{" + nameof(Score) + "}")] + public class BrStatsV2V1SquadStats : IEquatable + { + [J] public long Score { get; private set; } + [J] public double ScorePerMin { get; private set; } + [J] public double ScorePerMatch { get; private set; } + [J] public long Wins { get; private set; } + [J] public long Top3 { get; private set; } + [J] public long Top6 { get; private set; } + [J] public long Kills { get; private set; } + [J] public double KillsPerMin { get; private set; } + [J] public double KillsPerMatch { get; private set; } + [J] public long Deaths { get; private set; } + [J] public double Kd { get; private set; } + [J] public long Matches { get; private set; } + [J] public double WinRate { get; private set; } + [J] public long MinutesPlayed { get; private set; } + [J] public long PlayersOutlived { get; private set; } + [J] public DateTime LastModified { get; private set; } + + public bool Equals(BrStatsV2V1SquadStats other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Score == other.Score && Wins == other.Wins && Kills == other.Kills && Matches == other.Matches && LastModified.Equals(other.LastModified); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrStatsV2V1SquadStats)obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Score.GetHashCode(); + hashCode = hashCode * 397 ^ Wins.GetHashCode(); + hashCode = hashCode * 397 ^ Kills.GetHashCode(); + hashCode = hashCode * 397 ^ Matches.GetHashCode(); + hashCode = hashCode * 397 ^ LastModified.GetHashCode(); + return hashCode; + } + } + + public static bool operator ==(BrStatsV2V1SquadStats left, BrStatsV2V1SquadStats right) + { + return Equals(left, right); + } + + public static bool operator !=(BrStatsV2V1SquadStats left, BrStatsV2V1SquadStats right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V1/BrStatsV2V1Stats.cs b/src/Fortnite-API/Objects/V1/BrStatsV2V1Stats.cs new file mode 100644 index 0000000..3de754d --- /dev/null +++ b/src/Fortnite-API/Objects/V1/BrStatsV2V1Stats.cs @@ -0,0 +1,71 @@ +using System; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V1 +{ + public class BrStatsV2V1Stats : IEquatable + { + [J] public BrStatsV2V1StatsPlatform All { get; private set; } + [J] public BrStatsV2V1StatsPlatform KeyboardMouse { get; private set; } + [J] public BrStatsV2V1StatsPlatform Gamepad { get; private set; } + [J] public BrStatsV2V1StatsPlatform Touch { get; private set; } + + public bool Equals(BrStatsV2V1Stats other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Equals(All, other.All) && Equals(KeyboardMouse, other.KeyboardMouse) && Equals(Gamepad, other.Gamepad) && Equals(Touch, other.Touch); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrStatsV2V1Stats)obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = All.GetHashCode(); + hashCode = hashCode * 397 ^ (KeyboardMouse != null ? KeyboardMouse.GetHashCode() : 0); + hashCode = hashCode * 397 ^ (Gamepad != null ? Gamepad.GetHashCode() : 0); + hashCode = hashCode * 397 ^ (Touch != null ? Touch.GetHashCode() : 0); + return hashCode; + } + } + + public static bool operator ==(BrStatsV2V1Stats left, BrStatsV2V1Stats right) + { + return Equals(left, right); + } + + public static bool operator !=(BrStatsV2V1Stats left, BrStatsV2V1Stats right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V1/BrStatsV2V1StatsPlatform.cs b/src/Fortnite-API/Objects/V1/BrStatsV2V1StatsPlatform.cs new file mode 100644 index 0000000..058613e --- /dev/null +++ b/src/Fortnite-API/Objects/V1/BrStatsV2V1StatsPlatform.cs @@ -0,0 +1,75 @@ +using System; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V1 +{ + public class BrStatsV2V1StatsPlatform : IEquatable + { + [J] public BrStatsV2V1OverallStats Overall { get; private set; } + [J] public BrStatsV2V1SoloStats Solo { get; private set; } + [J] public BrStatsV2V1DuoStats Duo { get; private set; } + [J] public BrStatsV2V1SquadStats Trio { get; private set; } + [J] public BrStatsV2V1SquadStats Squad { get; private set; } + [J] public BrStatsV2V1LtmStats Ltm { get; private set; } + + public bool Equals(BrStatsV2V1StatsPlatform other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Equals(Overall, other.Overall) && Equals(Solo, other.Solo) && Equals(Duo, other.Duo) && Equals(Trio, other.Trio) && Equals(Squad, other.Squad) && Equals(Ltm, other.Ltm); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrStatsV2V1StatsPlatform)obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Overall.GetHashCode(); + hashCode = hashCode * 397 ^ (Solo != null ? Solo.GetHashCode() : 0); + hashCode = hashCode * 397 ^ (Duo != null ? Duo.GetHashCode() : 0); + hashCode = hashCode * 397 ^ (Trio != null ? Trio.GetHashCode() : 0); + hashCode = hashCode * 397 ^ (Squad != null ? Squad.GetHashCode() : 0); + hashCode = hashCode * 397 ^ (Ltm != null ? Ltm.GetHashCode() : 0); + return hashCode; + } + } + + public static bool operator ==(BrStatsV2V1StatsPlatform left, BrStatsV2V1StatsPlatform right) + { + return Equals(left, right); + } + + public static bool operator !=(BrStatsV2V1StatsPlatform left, BrStatsV2V1StatsPlatform right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V1/BrStatsV2V1TimeWindow.cs b/src/Fortnite-API/Objects/V1/BrStatsV2V1TimeWindow.cs new file mode 100644 index 0000000..810a537 --- /dev/null +++ b/src/Fortnite-API/Objects/V1/BrStatsV2V1TimeWindow.cs @@ -0,0 +1,8 @@ +namespace Fortnite_API.Objects.V1 +{ + public enum BrStatsV2V1TimeWindow + { + Lifetime, + Season + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V1/CombinedNewsV1.cs b/src/Fortnite-API/Objects/V1/CombinedNewsV1.cs index 8709500..c88ac61 100644 --- a/src/Fortnite-API/Objects/V1/CombinedNewsV1.cs +++ b/src/Fortnite-API/Objects/V1/CombinedNewsV1.cs @@ -6,9 +6,9 @@ namespace Fortnite_API.Objects.V1 { public class CombinedNewsV1 : IEquatable { - [J("br")] public NewsV1 Br { get; private set; } - [J("stw")] public NewsV1 Stw { get; private set; } - [J("creative")] public NewsV1 Creative { get; private set; } + [J] public NewsV1 Br { get; private set; } + [J] public NewsV1 Stw { get; private set; } + [J] public NewsV1 Creative { get; private set; } public bool Equals(CombinedNewsV1 other) { diff --git a/src/Fortnite-API/Objects/V1/CreatorCodeV1.cs b/src/Fortnite-API/Objects/V1/CreatorCodeV1.cs index fe91087..3ce0b00 100644 --- a/src/Fortnite-API/Objects/V1/CreatorCodeV1.cs +++ b/src/Fortnite-API/Objects/V1/CreatorCodeV1.cs @@ -6,11 +6,11 @@ namespace Fortnite_API.Objects.V1 { public class CreatorCodeV1 : IEquatable { - [J("id")] public string Id { get; private set; } - [J("slug")] public string Slug { get; private set; } - [J("displayName")] public string DisplayName { get; private set; } - [J("status")] public string Status { get; private set; } - [J("verified")] public bool Verified { get; private set; } + [J] public string Id { get; private set; } + [J] public string Slug { get; private set; } + [J] public string DisplayName { get; private set; } + [J] public string Status { get; private set; } + [J] public bool Verified { get; private set; } public bool Equals(CreatorCodeV1 other) { diff --git a/src/Fortnite-API/Objects/V1/ImageV1Data.cs b/src/Fortnite-API/Objects/V1/ImageV1Data.cs index f7b6d33..6f6cd9d 100644 --- a/src/Fortnite-API/Objects/V1/ImageV1Data.cs +++ b/src/Fortnite-API/Objects/V1/ImageV1Data.cs @@ -1,13 +1,15 @@ using System; +using I = Newtonsoft.Json.JsonIgnoreAttribute; using J = Newtonsoft.Json.JsonPropertyAttribute; namespace Fortnite_API.Objects.V1 { public class ImageV1Data : IEquatable { - [J("hash")] public string Hash { get; private set; } - [J("url")] public Uri Url { get; private set; } + [Obsolete("This property will always return null.")] + [I] public string Hash { get; } = null; + [J] public Uri Url { get; private set; } public bool Equals(ImageV1Data other) { @@ -21,7 +23,7 @@ public bool Equals(ImageV1Data other) return true; } - return Hash == other.Hash && Equals(Url, other.Url); + return Url.Equals(other.Url); } public override bool Equals(object obj) @@ -36,7 +38,7 @@ public override bool Equals(object obj) return true; } - if (obj.GetType() != typeof(ImageV1Data)) + if (obj.GetType() != GetType()) { return false; } @@ -46,10 +48,7 @@ public override bool Equals(object obj) public override int GetHashCode() { - unchecked - { - return (Hash != null ? Hash.GetHashCode() : 0) * 397 ^ (Url != null ? Url.GetHashCode() : 0); - } + return Url.GetHashCode(); } public static bool operator ==(ImageV1Data left, ImageV1Data right) diff --git a/src/Fortnite-API/Objects/V1/NewsV1.cs b/src/Fortnite-API/Objects/V1/NewsV1.cs index 832608c..ace092e 100644 --- a/src/Fortnite-API/Objects/V1/NewsV1.cs +++ b/src/Fortnite-API/Objects/V1/NewsV1.cs @@ -7,11 +7,11 @@ namespace Fortnite_API.Objects.V1 { public class NewsV1 : IEquatable { - [J("language")] public string Language; - [J("title")] public string Title; - [J("lastModified")] public DateTime LastModified; - [J("motds")] public List Motds; - [J("messages")] public List Messages; + [J] public string Language; + [J] public string Title; + [J] public DateTime LastModified; + [J] public List Motds; + [J] public List Messages; public bool Equals(NewsV1 other) { diff --git a/src/Fortnite-API/Objects/V1/NewsV1Message.cs b/src/Fortnite-API/Objects/V1/NewsV1Message.cs index b7b3b15..d2070df 100644 --- a/src/Fortnite-API/Objects/V1/NewsV1Message.cs +++ b/src/Fortnite-API/Objects/V1/NewsV1Message.cs @@ -6,14 +6,14 @@ namespace Fortnite_API.Objects.V1 { public class NewsV1Message : IEquatable { - [J("image")] public Uri ImageUrl { get; private set; } - [J("hidden")] public bool Hidden { get; private set; } - [J("messageType")] public string MessageType { get; private set; } - [J("type")] public string Type { get; private set; } - [J("adspace")] public string Adspace { get; private set; } - [J("title")] public string Title { get; private set; } - [J("body")] public string Body { get; private set; } - [J("spotlight")] public bool Spotlight { get; private set; } + [J] public Uri Image { get; private set; } + [J] public bool Hidden { get; private set; } + [J] public string MessageType { get; private set; } + [J] public string Type { get; private set; } + [J] public string Adspace { get; private set; } + [J] public string Title { get; private set; } + [J] public string Body { get; private set; } + [J] public bool Spotlight { get; private set; } public bool Equals(NewsV1Message other) { @@ -27,7 +27,7 @@ public bool Equals(NewsV1Message other) return true; } - return Equals(ImageUrl, other.ImageUrl) && Hidden == other.Hidden && MessageType == other.MessageType && Type == other.Type && Adspace == other.Adspace && Title == other.Title && Body == other.Body && Spotlight == other.Spotlight; + return Equals(Image, other.Image) && Hidden == other.Hidden && MessageType == other.MessageType && Type == other.Type && Adspace == other.Adspace && Title == other.Title && Body == other.Body && Spotlight == other.Spotlight; } public override bool Equals(object obj) @@ -54,7 +54,7 @@ public override int GetHashCode() { unchecked { - var hashCode = ImageUrl != null ? ImageUrl.GetHashCode() : 0; + var hashCode = Image != null ? Image.GetHashCode() : 0; hashCode = hashCode * 397 ^ Hidden.GetHashCode(); hashCode = hashCode * 397 ^ (MessageType != null ? MessageType.GetHashCode() : 0); hashCode = hashCode * 397 ^ (Type != null ? Type.GetHashCode() : 0); diff --git a/src/Fortnite-API/Objects/V1/NewsV1Motd.cs b/src/Fortnite-API/Objects/V1/NewsV1Motd.cs index 1b680bd..16cc9bf 100644 --- a/src/Fortnite-API/Objects/V1/NewsV1Motd.cs +++ b/src/Fortnite-API/Objects/V1/NewsV1Motd.cs @@ -6,15 +6,15 @@ namespace Fortnite_API.Objects.V1 { public class NewsV1Motd : IEquatable { - [J("id")] public string Id { get; private set; } - [J("title")] public string Title { get; private set; } - [J("body")] public string Body { get; private set; } - [J("image")] public Uri Image { get; private set; } - [J("tileImage")] public Uri TileImage { get; private set; } - [J("hidden")] public bool Hidden { get; private set; } - [J("spotlight")] public bool Spotlight { get; private set; } - [J("type")] public string Type { get; private set; } - [J("entryType")] public string EntryType { get; private set; } + [J] public string Id { get; private set; } + [J] public string Title { get; private set; } + [J] public string Body { get; private set; } + [J] public Uri Image { get; private set; } + [J] public Uri TileImage { get; private set; } + [J] public bool Hidden { get; private set; } + [J] public bool Spotlight { get; private set; } + [J] public string Type { get; private set; } + [J] public string EntryType { get; private set; } public bool Equals(NewsV1Motd other) { diff --git a/src/Fortnite-API/Objects/V2/AesV2.cs b/src/Fortnite-API/Objects/V2/AesV2.cs new file mode 100644 index 0000000..74b8006 --- /dev/null +++ b/src/Fortnite-API/Objects/V2/AesV2.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(Build) + "}")] + public class AesV2 : IEquatable + { + [J] public string Build { get; private set; } + [J] public string MainKey { get; private set; } + [J] public List DynamicKeys { get; private set; } + [J] public DateTime Updated { get; private set; } + + public bool HasDynamicKeys => DynamicKeys != null; + + public bool Equals(AesV2 other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Build == other.Build && MainKey == other.MainKey && DynamicKeys.Equals(other.DynamicKeys) && Updated.Equals(other.Updated); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((AesV2)obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Build.GetHashCode(); + hashCode = hashCode * 397 ^ MainKey.GetHashCode(); + hashCode = hashCode * 397 ^ DynamicKeys.GetHashCode(); + hashCode = hashCode * 397 ^ Updated.GetHashCode(); + return hashCode; + } + } + + public static bool operator ==(AesV2 left, AesV2 right) + { + return Equals(left, right); + } + + public static bool operator !=(AesV2 left, AesV2 right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/AesV2DynamicKey.cs b/src/Fortnite-API/Objects/V2/AesV2DynamicKey.cs new file mode 100644 index 0000000..a692ef5 --- /dev/null +++ b/src/Fortnite-API/Objects/V2/AesV2DynamicKey.cs @@ -0,0 +1,68 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(PakGuid) + "}")] + public class AesV2DynamicKey : IEquatable + { + [J] public string PakFilename { get; private set; } + [J] public string PakGuid { get; private set; } + [J] public string Key { get; private set; } + + public bool Equals(AesV2DynamicKey other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return PakGuid == other.PakGuid && Key == other.Key; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((AesV2DynamicKey)obj); + } + + public override int GetHashCode() + { + unchecked + { + return (PakGuid.GetHashCode() * 397) ^ Key.GetHashCode(); + } + } + + public static bool operator ==(AesV2DynamicKey left, AesV2DynamicKey right) + { + return Equals(left, right); + } + + public static bool operator !=(AesV2DynamicKey left, AesV2DynamicKey right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/AesV2KeyFormat.cs b/src/Fortnite-API/Objects/V2/AesV2KeyFormat.cs new file mode 100644 index 0000000..6f7a64a --- /dev/null +++ b/src/Fortnite-API/Objects/V2/AesV2KeyFormat.cs @@ -0,0 +1,8 @@ +namespace Fortnite_API.Objects.V2 +{ + public enum AesV2KeyFormat + { + Hex, + Base64 + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/BrCosmeticV2.cs b/src/Fortnite-API/Objects/V2/BrCosmeticV2.cs new file mode 100644 index 0000000..57f990c --- /dev/null +++ b/src/Fortnite-API/Objects/V2/BrCosmeticV2.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; + +using I = Newtonsoft.Json.JsonIgnoreAttribute; +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(Id) + "}")] + public class BrCosmeticV2 : IEquatable + { + private static readonly Uri _youtubeBaseUri = new Uri("https://youtu.be"); + + [J] public string Id { get; private set; } + [J] public string Name { get; private set; } + [J] public string Description { get; private set; } + [J] public BrCosmeticV2Type Type { get; private set; } + [J] public BrCosmeticV2Rarity Rarity { get; private set; } + [J] public BrCosmeticV2Series Series { get; private set; } + [J] public BrCosmeticV2Set Set { get; private set; } + [J] public BrCosmeticV2Introduction Introduction { get; private set; } + [J] public BrCosmeticV2Images Images { get; private set; } + [J] public List Variants { get; private set; } + [J] public List GameplayTags { get; private set; } + private string _showcaseVideo; + [J] public string ShowcaseVideo + { + get => _showcaseVideo; + private set => ShowcaseVideoUri = new Uri(_youtubeBaseUri, _showcaseVideo = value); + } + [I] public Uri ShowcaseVideoUri { get; private set; } + [J] public string DisplayAssetPath { get; private set; } + [J] public string DefinitionPath { get; private set; } + [J] public string Path { get; private set; } + [J] public DateTime Added { get; private set; } + [J] public List ShopHistory { get; private set; } + + public bool HasSeries => Series != null; + public bool HasSet => Set != null; + public bool HasIntroduction => Introduction != null; + public bool HasVariants => Variants != null && Variants.Count != 0; + public bool HasGameplayTags => GameplayTags != null && GameplayTags.Count != 0; + public bool HasShowcaseVideo => ShowcaseVideo != null; + public bool HasDisplayAssetPath => DisplayAssetPath != null; + public bool HasDefinitionPath => DefinitionPath != null; + public bool HasShopHistory => ShopHistory != null; + + public bool Equals(BrCosmeticV2 other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Id == other.Id; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrCosmeticV2)obj); + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + + public static bool operator ==(BrCosmeticV2 left, BrCosmeticV2 right) + { + return Equals(left, right); + } + + public static bool operator !=(BrCosmeticV2 left, BrCosmeticV2 right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/BrCosmeticV2Images.cs b/src/Fortnite-API/Objects/V2/BrCosmeticV2Images.cs new file mode 100644 index 0000000..2bb3a1d --- /dev/null +++ b/src/Fortnite-API/Objects/V2/BrCosmeticV2Images.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + public class BrCosmeticV2Images : IEquatable + { + [J] public Uri SmallIcon { get; private set; } + [J] public Uri Icon { get; private set; } + [J] public Uri Featured { get; private set; } + [J] public Dictionary Other { get; private set; } + + public bool Equals(BrCosmeticV2Images other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return SmallIcon == other.SmallIcon && Icon == other.Icon && Featured == other.Featured && Equals(Other, other.Other); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrCosmeticV2Images)obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = SmallIcon != null ? SmallIcon.GetHashCode() : 0; + hashCode = hashCode * 397 ^ (Icon != null ? Icon.GetHashCode() : 0); + hashCode = hashCode * 397 ^ (Featured != null ? Featured.GetHashCode() : 0); + hashCode = hashCode * 397 ^ (Other != null ? Other.GetHashCode() : 0); + return hashCode; + } + } + + public static bool operator ==(BrCosmeticV2Images left, BrCosmeticV2Images right) + { + return Equals(left, right); + } + + public static bool operator !=(BrCosmeticV2Images left, BrCosmeticV2Images right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/BrCosmeticV2Introduction.cs b/src/Fortnite-API/Objects/V2/BrCosmeticV2Introduction.cs new file mode 100644 index 0000000..8ad19bb --- /dev/null +++ b/src/Fortnite-API/Objects/V2/BrCosmeticV2Introduction.cs @@ -0,0 +1,66 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(BackendValue) + "}")] + public class BrCosmeticV2Introduction : IEquatable + { + [J] public string Chapter { get; private set; } + [J] public string Season { get; private set; } + [J] public string Text { get; private set; } + [J] public int BackendValue { get; private set; } + + public bool Equals(BrCosmeticV2Introduction other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return BackendValue == other.BackendValue; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrCosmeticV2Introduction)obj); + } + + public override int GetHashCode() + { + return BackendValue; + } + + public static bool operator ==(BrCosmeticV2Introduction left, BrCosmeticV2Introduction right) + { + return Equals(left, right); + } + + public static bool operator !=(BrCosmeticV2Introduction left, BrCosmeticV2Introduction right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/BrCosmeticV2Rarity.cs b/src/Fortnite-API/Objects/V2/BrCosmeticV2Rarity.cs new file mode 100644 index 0000000..44f1ee6 --- /dev/null +++ b/src/Fortnite-API/Objects/V2/BrCosmeticV2Rarity.cs @@ -0,0 +1,65 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(BackendValue) + "}")] + public class BrCosmeticV2Rarity : IEquatable + { + [J] public string Value { get; private set; } + [J] public string DisplayValue { get; private set; } + [J] public string BackendValue { get; private set; } + + public bool Equals(BrCosmeticV2Rarity other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return BackendValue == other.BackendValue; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrCosmeticV2Rarity)obj); + } + + public override int GetHashCode() + { + return BackendValue.GetHashCode(); + } + + public static bool operator ==(BrCosmeticV2Rarity left, BrCosmeticV2Rarity right) + { + return Equals(left, right); + } + + public static bool operator !=(BrCosmeticV2Rarity left, BrCosmeticV2Rarity right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/BrCosmeticV2SearchProperties.cs b/src/Fortnite-API/Objects/V2/BrCosmeticV2SearchProperties.cs new file mode 100644 index 0000000..fb90779 --- /dev/null +++ b/src/Fortnite-API/Objects/V2/BrCosmeticV2SearchProperties.cs @@ -0,0 +1,219 @@ +using System; + +using RestSharp; + +namespace Fortnite_API.Objects.V2 +{ + public class BrCosmeticV2SearchProperties + { + private static readonly DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + + public Optional Language { get; set; } + public Optional SearchLanguage { get; set; } + public Optional MatchMethod { get; set; } + public Optional Id { get; set; } + public Optional Name { get; set; } + public Optional Description { get; set; } + public Optional Type { get; set; } + public Optional DisplayType { get; set; } + public Optional BackendType { get; set; } + public Optional Rarity { get; set; } + public Optional DisplayRarity { get; set; } + public Optional BackendRarity { get; set; } + public Optional HasSeries { get; set; } + public Optional Series { get; set; } + public Optional BackendSeries { get; set; } + public Optional HasSet { get; set; } + public Optional Set { get; set; } + public Optional SetText { get; set; } + public Optional BackendSet { get; set; } + public Optional HasIntroduction { get; set; } + public Optional IntroductionChapter { get; set; } + public Optional IntroductionSeason { get; set; } + public Optional HasFeaturedImage { get; set; } + public Optional HasVariants { get; set; } + public Optional HasGameplayTags { get; set; } + public Optional GameplayTag { get; set; } + public Optional Added { get; set; } + public Optional AddedSince { get; set; } + public Optional UnseenFor { get; set; } + public Optional LastAppearance { get; set; } + + internal IRestRequest AppendParameters(IRestRequest request) + { + if (Language.HasValue) + { + request.AddQueryParameter("language", Language.Value.GetLanguageCode()); + } + + if (SearchLanguage.HasValue) + { + request.AddQueryParameter("searchLanguage", SearchLanguage.Value.GetLanguageCode()); + } + + if (MatchMethod.HasValue) + { + request.AddQueryParameter("matchMethod", MatchMethod.Value.GetString()); + } + + var paramsCount = request.Parameters.Count; + + if (Id.HasValue) + { + request.AddQueryParameter("id", Id.Value); + } + + if (Name.HasValue) + { + request.AddQueryParameter("name", Name.Value); + } + + if (Description.HasValue) + { + request.AddQueryParameter("description", Description.Value); + } + + if (Type.HasValue) + { + request.AddQueryParameter("type", Type.Value); + } + + if (DisplayType.HasValue) + { + request.AddQueryParameter("displayType", DisplayType.Value); + } + + if (BackendType.HasValue) + { + request.AddQueryParameter("backendType", BackendType.Value); + } + + if (Rarity.HasValue) + { + request.AddQueryParameter("rarity", Rarity.Value); + } + + if (DisplayRarity.HasValue) + { + request.AddQueryParameter("displayRarity", DisplayRarity.Value); + } + + if (BackendRarity.HasValue) + { + request.AddQueryParameter("backendRarity", BackendRarity.Value); + } + + if (HasSeries.HasValue) + { + request.AddQueryParameter("hasSeries", HasSeries.Value.GetString()); + } + + if (Series.HasValue) + { + request.AddQueryParameter("series", Series.Value); + } + + if (BackendSeries.HasValue) + { + request.AddQueryParameter("backendSeries", BackendSeries.Value); + } + + if (HasSet.HasValue) + { + request.AddQueryParameter("hasSet", HasSet.Value.GetString()); + } + + if (Set.HasValue) + { + request.AddQueryParameter("set", Set.Value); + } + + if (SetText.HasValue) + { + request.AddQueryParameter("setText", SetText.Value); + } + + if (BackendSet.HasValue) + { + request.AddQueryParameter("backendSet", BackendSet.Value); + } + + if (HasIntroduction.HasValue) + { + request.AddQueryParameter("hasIntroduction", HasIntroduction.Value.GetString()); + } + + if (IntroductionChapter.HasValue) + { + request.AddQueryParameter("introductionChapter", IntroductionChapter.Value); + } + + if (IntroductionSeason.HasValue) + { + request.AddQueryParameter("introductionSeason", IntroductionSeason.Value); + } + + if (HasFeaturedImage.HasValue) + { + request.AddQueryParameter("hasFeaturedImage", HasFeaturedImage.Value.GetString()); + } + + if (HasVariants.HasValue) + { + request.AddQueryParameter("hasVariants", HasVariants.Value.GetString()); + } + + if (HasGameplayTags.HasValue) + { + request.AddQueryParameter("hasGameplayTags", HasGameplayTags.Value.GetString()); + } + + if (GameplayTag.HasValue) + { + request.AddQueryParameter("gameplayTag", GameplayTag.Value); + } + + if (Added.HasValue) + { + if (Added.Value <= _unixEpoch) + { + throw new ArgumentOutOfRangeException(nameof(Added)); + } + + request.AddQueryParameter("added", (Added.Value - _unixEpoch).TotalSeconds.ToString("0")); + } + + if (AddedSince.HasValue) + { + if (AddedSince.Value <= _unixEpoch) + { + throw new ArgumentOutOfRangeException(nameof(AddedSince)); + } + + request.AddQueryParameter("addedSince", (AddedSince.Value - _unixEpoch).TotalSeconds.ToString("0")); + } + + if (UnseenFor.HasValue) + { + request.AddQueryParameter("unseenFor", UnseenFor.Value.ToString()); + } + + if (LastAppearance.HasValue) + { + if (LastAppearance.Value <= _unixEpoch) + { + throw new ArgumentOutOfRangeException(nameof(LastAppearance)); + } + + request.AddQueryParameter("lastAppearance", (LastAppearance.Value - _unixEpoch).TotalSeconds.ToString("0")); + } + + if (request.Parameters.Count - paramsCount == 0) + { + throw new ArgumentException("at least one search parameter is required"); + } + + return request; + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/BrCosmeticV2Series.cs b/src/Fortnite-API/Objects/V2/BrCosmeticV2Series.cs new file mode 100644 index 0000000..7b804b9 --- /dev/null +++ b/src/Fortnite-API/Objects/V2/BrCosmeticV2Series.cs @@ -0,0 +1,65 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(BackendValue) + "}")] + public class BrCosmeticV2Series : IEquatable + { + [J] public string Value { get; private set; } + [J] public Uri Image { get; private set; } + [J] public string BackendValue { get; private set; } + + public bool Equals(BrCosmeticV2Series other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return BackendValue == other.BackendValue; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrCosmeticV2Series)obj); + } + + public override int GetHashCode() + { + return BackendValue.GetHashCode(); + } + + public static bool operator ==(BrCosmeticV2Series left, BrCosmeticV2Series right) + { + return Equals(left, right); + } + + public static bool operator !=(BrCosmeticV2Series left, BrCosmeticV2Series right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/BrCosmeticV2Set.cs b/src/Fortnite-API/Objects/V2/BrCosmeticV2Set.cs new file mode 100644 index 0000000..72ce39d --- /dev/null +++ b/src/Fortnite-API/Objects/V2/BrCosmeticV2Set.cs @@ -0,0 +1,65 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(BackendValue) + "}")] + public class BrCosmeticV2Set : IEquatable + { + [J] public string Value { get; private set; } + [J] public string Text { get; private set; } + [J] public string BackendValue { get; private set; } + + public bool Equals(BrCosmeticV2Set other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return BackendValue == other.BackendValue; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrCosmeticV2Set)obj); + } + + public override int GetHashCode() + { + return BackendValue.GetHashCode(); + } + + public static bool operator ==(BrCosmeticV2Set left, BrCosmeticV2Set right) + { + return Equals(left, right); + } + + public static bool operator !=(BrCosmeticV2Set left, BrCosmeticV2Set right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/BrCosmeticV2Type.cs b/src/Fortnite-API/Objects/V2/BrCosmeticV2Type.cs new file mode 100644 index 0000000..e36c1dd --- /dev/null +++ b/src/Fortnite-API/Objects/V2/BrCosmeticV2Type.cs @@ -0,0 +1,65 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(BackendValue) + "}")] + public class BrCosmeticV2Type : IEquatable + { + [J] public string Value { get; private set; } + [J] public string DisplayValue { get; private set; } + [J] public string BackendValue { get; private set; } + + public bool Equals(BrCosmeticV2Type other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return BackendValue == other.BackendValue; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrCosmeticV2Type)obj); + } + + public override int GetHashCode() + { + return BackendValue.GetHashCode(); + } + + public static bool operator ==(BrCosmeticV2Type left, BrCosmeticV2Type right) + { + return Equals(left, right); + } + + public static bool operator !=(BrCosmeticV2Type left, BrCosmeticV2Type right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/BrCosmeticV2Variant.cs b/src/Fortnite-API/Objects/V2/BrCosmeticV2Variant.cs new file mode 100644 index 0000000..c298498 --- /dev/null +++ b/src/Fortnite-API/Objects/V2/BrCosmeticV2Variant.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(Channel) + "}")] + public class BrCosmeticV2Variant : IEquatable + { + [J] public string Channel { get; private set; } + [J] public string Type { get; private set; } + [J] public List Options { get; private set; } + + public bool Equals(BrCosmeticV2Variant other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Channel == other.Channel && Options.Equals(other.Options); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrCosmeticV2Variant)obj); + } + + public override int GetHashCode() + { + unchecked + { + return Channel.GetHashCode() * 397 ^ Options.GetHashCode(); + } + } + + public static bool operator ==(BrCosmeticV2Variant left, BrCosmeticV2Variant right) + { + return Equals(left, right); + } + + public static bool operator !=(BrCosmeticV2Variant left, BrCosmeticV2Variant right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/BrCosmeticV2VariantOption.cs b/src/Fortnite-API/Objects/V2/BrCosmeticV2VariantOption.cs new file mode 100644 index 0000000..2aeed83 --- /dev/null +++ b/src/Fortnite-API/Objects/V2/BrCosmeticV2VariantOption.cs @@ -0,0 +1,65 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(Tag) + "}")] + public class BrCosmeticV2VariantOption : IEquatable + { + [J] public string Tag { get; private set; } + [J] public string Name { get; private set; } + [J] public Uri Image { get; private set; } + + public bool Equals(BrCosmeticV2VariantOption other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Tag == other.Tag; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrCosmeticV2VariantOption)obj); + } + + public override int GetHashCode() + { + return Tag.GetHashCode(); + } + + public static bool operator ==(BrCosmeticV2VariantOption left, BrCosmeticV2VariantOption right) + { + return Equals(left, right); + } + + public static bool operator !=(BrCosmeticV2VariantOption left, BrCosmeticV2VariantOption right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/BrShopV2.cs b/src/Fortnite-API/Objects/V2/BrShopV2.cs new file mode 100644 index 0000000..652f8e4 --- /dev/null +++ b/src/Fortnite-API/Objects/V2/BrShopV2.cs @@ -0,0 +1,80 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(Date) + "}")] + public class BrShopV2 : IEquatable + { + [J] public string Hash { get; private set; } + [J] public DateTime Date { get; private set; } + [J] public BrShopV2StoreFront Featured { get; private set; } + [J] public BrShopV2StoreFront Daily { get; private set; } + [J] public BrShopV2StoreFront SpecialFeatured { get; private set; } + [J] public BrShopV2StoreFront SpecialDaily { get; private set; } + [J] public BrShopV2StoreFront Votes { get; private set; } + [J] public BrShopV2StoreFront VoteWinners { get; private set; } + + public bool HasFeatured => Featured != null; + public bool HasDaily => Daily != null; + public bool HasSpecialFeatured => SpecialFeatured != null; + public bool HasSpecialDaily => SpecialDaily != null; + public bool HasVotes => Votes != null; + public bool HasVoteWinners => VoteWinners != null; + + public bool Equals(BrShopV2 other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Hash == other.Hash && Date.Equals(other.Date); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrShopV2)obj); + } + + public override int GetHashCode() + { + unchecked + { + return Hash.GetHashCode() * 397 ^ Date.GetHashCode(); + } + } + + public static bool operator ==(BrShopV2 left, BrShopV2 right) + { + return Equals(left, right); + } + + public static bool operator !=(BrShopV2 left, BrShopV2 right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/BrShopV2Combined.cs b/src/Fortnite-API/Objects/V2/BrShopV2Combined.cs new file mode 100644 index 0000000..d8a65cc --- /dev/null +++ b/src/Fortnite-API/Objects/V2/BrShopV2Combined.cs @@ -0,0 +1,76 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(Date) + "}")] + public class BrShopV2Combined : IEquatable + { + [J] public string Hash { get; private set; } + [J] public DateTime Date { get; private set; } + [J] public BrShopV2StoreFront Featured { get; private set; } + [J] public BrShopV2StoreFront Daily { get; private set; } + [J] public BrShopV2StoreFront Votes { get; private set; } + [J] public BrShopV2StoreFront VoteWinners { get; private set; } + + public bool HasFeatured => Featured != null; + public bool HasDaily => Daily != null; + public bool HasVotes => Votes != null; + public bool HasVoteWinners => VoteWinners != null; + + public bool Equals(BrShopV2Combined other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Hash == other.Hash && Date.Equals(other.Date); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrShopV2Combined)obj); + } + + public override int GetHashCode() + { + unchecked + { + return Hash.GetHashCode() * 397 ^ Date.GetHashCode(); + } + } + + public static bool operator ==(BrShopV2Combined left, BrShopV2Combined right) + { + return Equals(left, right); + } + + public static bool operator !=(BrShopV2Combined left, BrShopV2Combined right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/BrShopV2StoreFront.cs b/src/Fortnite-API/Objects/V2/BrShopV2StoreFront.cs new file mode 100644 index 0000000..cf56141 --- /dev/null +++ b/src/Fortnite-API/Objects/V2/BrShopV2StoreFront.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(Entries) + "}")] + public class BrShopV2StoreFront : IEquatable + { + [J] public string Name { get; private set; } + [J] public List Entries { get; private set; } + + public bool HasName => Name != null; + + public bool Equals(BrShopV2StoreFront other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Name == other.Name && Equals(Entries, other.Entries); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrShopV2StoreFront)obj); + } + + public override int GetHashCode() + { + unchecked + { + return (Name != null ? Name.GetHashCode() : 0) * 397 ^ Entries.GetHashCode(); + } + } + + public static bool operator ==(BrShopV2StoreFront left, BrShopV2StoreFront right) + { + return Equals(left, right); + } + + public static bool operator !=(BrShopV2StoreFront left, BrShopV2StoreFront right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/BrShopV2StoreFrontEntry.cs b/src/Fortnite-API/Objects/V2/BrShopV2StoreFrontEntry.cs new file mode 100644 index 0000000..e61fc57 --- /dev/null +++ b/src/Fortnite-API/Objects/V2/BrShopV2StoreFrontEntry.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(DevName) + "}")] + public class BrShopV2StoreFrontEntry : IEquatable + { + [J] public int RegularPrice { get; private set; } + [J] public int FinalPrice { get; private set; } + [J] public BrShopV2StoreFrontEntryBundle Bundle { get; private set; } + [J] public BrShopV2StoreFrontEntryBanner Banner { get; private set; } + [J] public bool Giftable { get; private set; } + [J] public bool Refundable { get; private set; } + [J] public int SortPriority { get; private set; } + [J] public List Categories { get; private set; } + [J] public string DevName { get; private set; } + [J] public string OfferId { get; private set; } + [J] public string DisplayAssetPath { get; private set; } + [J] public List Items { get; private set; } + + public bool IsBundle => Bundle != null; + public bool HasBanner => Banner != null; + public bool HasCategories => Categories != null && Categories.Count != 0; + public bool IsDiscounted => FinalPrice < RegularPrice; + public bool HasDisplayAssetPath => DisplayAssetPath != null; + + public bool Equals(BrShopV2StoreFrontEntry other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return DevName == other.DevName && OfferId == other.OfferId; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != this.GetType()) + { + return false; + } + + return Equals((BrShopV2StoreFrontEntry)obj); + } + + public override int GetHashCode() + { + unchecked + { + return DevName.GetHashCode() * 397 ^ OfferId.GetHashCode(); + } + } + + public static bool operator ==(BrShopV2StoreFrontEntry left, BrShopV2StoreFrontEntry right) + { + return Equals(left, right); + } + + public static bool operator !=(BrShopV2StoreFrontEntry left, BrShopV2StoreFrontEntry right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/BrShopV2StoreFrontEntryBanner.cs b/src/Fortnite-API/Objects/V2/BrShopV2StoreFrontEntryBanner.cs new file mode 100644 index 0000000..ff0c54b --- /dev/null +++ b/src/Fortnite-API/Objects/V2/BrShopV2StoreFrontEntryBanner.cs @@ -0,0 +1,67 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(BackendValue) + "}")] + public class BrShopV2StoreFrontEntryBanner : IEquatable + { + [J] public string Value { get; private set; } + [J] public string BackendValue { get; private set; } + + public bool Equals(BrShopV2StoreFrontEntryBanner other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Value == other.Value && BackendValue == other.BackendValue; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrShopV2StoreFrontEntryBanner)obj); + } + + public override int GetHashCode() + { + unchecked + { + return Value.GetHashCode() * 397 ^ BackendValue.GetHashCode(); + } + } + + public static bool operator ==(BrShopV2StoreFrontEntryBanner left, BrShopV2StoreFrontEntryBanner right) + { + return Equals(left, right); + } + + public static bool operator !=(BrShopV2StoreFrontEntryBanner left, BrShopV2StoreFrontEntryBanner right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/BrShopV2StoreFrontEntryBundle.cs b/src/Fortnite-API/Objects/V2/BrShopV2StoreFrontEntryBundle.cs new file mode 100644 index 0000000..d237e19 --- /dev/null +++ b/src/Fortnite-API/Objects/V2/BrShopV2StoreFrontEntryBundle.cs @@ -0,0 +1,67 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(Name) + "}")] + public class BrShopV2StoreFrontEntryBundle : IEquatable + { + [J] public string Name { get; private set; } + [J] public Uri Image { get; private set; } + + public bool Equals(BrShopV2StoreFrontEntryBundle other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Name == other.Name && Image.Equals(other.Image); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((BrShopV2StoreFrontEntryBundle)obj); + } + + public override int GetHashCode() + { + unchecked + { + return Name.GetHashCode() * 397 ^ Image.GetHashCode(); + } + } + + public static bool operator ==(BrShopV2StoreFrontEntryBundle left, BrShopV2StoreFrontEntryBundle right) + { + return Equals(left, right); + } + + public static bool operator !=(BrShopV2StoreFrontEntryBundle left, BrShopV2StoreFrontEntryBundle right) + { + return !Equals(left, right); + } + } +} diff --git a/src/Fortnite-API/Objects/V2/CreatorCodeV2.cs b/src/Fortnite-API/Objects/V2/CreatorCodeV2.cs new file mode 100644 index 0000000..f7b7cd7 --- /dev/null +++ b/src/Fortnite-API/Objects/V2/CreatorCodeV2.cs @@ -0,0 +1,73 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(Code) + "}")] + public class CreatorCodeV2 : IEquatable + { + [J] public string Code { get; private set; } + [J] public AccountData Account { get; private set; } + [J] public string Status { get; private set; } + [J] public bool Verified { get; private set; } + + public bool Equals(CreatorCodeV2 other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Code == other.Code && Account.Equals(other.Account) && Status == other.Status && Verified == other.Verified; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((CreatorCodeV2)obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Code.GetHashCode(); + hashCode = hashCode * 397 ^ Account.GetHashCode(); + hashCode = hashCode * 397 ^ Status.GetHashCode(); + hashCode = hashCode * 397 ^ Verified.GetHashCode(); + return hashCode; + } + } + + public static bool operator ==(CreatorCodeV2 left, CreatorCodeV2 right) + { + return Equals(left, right); + } + + public static bool operator !=(CreatorCodeV2 left, CreatorCodeV2 right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/NewsV2.cs b/src/Fortnite-API/Objects/V2/NewsV2.cs new file mode 100644 index 0000000..004617c --- /dev/null +++ b/src/Fortnite-API/Objects/V2/NewsV2.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(Date) + "}")] + public class NewsV2 : IEquatable + { + [J] public string Hash { get; private set; } + [J] public DateTime Date { get; private set; } + [J] public Uri Image { get; private set; } + [J] public List Motds { get; private set; } + [J] public List Messages { get; private set; } + + public bool Equals(NewsV2 other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Hash == other.Hash && Date.Equals(other.Date); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((NewsV2)obj); + } + + public override int GetHashCode() + { + unchecked + { + return Hash.GetHashCode() * 397 ^ Date.GetHashCode(); + } + } + + public static bool operator ==(NewsV2 left, NewsV2 right) + { + return Equals(left, right); + } + + public static bool operator !=(NewsV2 left, NewsV2 right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/NewsV2Combined.cs b/src/Fortnite-API/Objects/V2/NewsV2Combined.cs new file mode 100644 index 0000000..29ef6da --- /dev/null +++ b/src/Fortnite-API/Objects/V2/NewsV2Combined.cs @@ -0,0 +1,69 @@ +using System; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + public class NewsV2Combined : IEquatable + { + [J] public NewsV2 Br { get; private set; } + [J] public NewsV2 Stw { get; private set; } + [J] public NewsV2 Creative { get; private set; } + + public bool Equals(NewsV2Combined other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Equals(Br, other.Br) && Equals(Stw, other.Stw) && Equals(Creative, other.Creative); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((NewsV2Combined)obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Br != null ? Br.GetHashCode() : 0; + hashCode = hashCode * 397 ^ (Stw != null ? Stw.GetHashCode() : 0); + hashCode = hashCode * 397 ^ (Creative != null ? Creative.GetHashCode() : 0); + return hashCode; + } + } + + public static bool operator ==(NewsV2Combined left, NewsV2Combined right) + { + return Equals(left, right); + } + + public static bool operator !=(NewsV2Combined left, NewsV2Combined right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/NewsV2Message.cs b/src/Fortnite-API/Objects/V2/NewsV2Message.cs new file mode 100644 index 0000000..9addda5 --- /dev/null +++ b/src/Fortnite-API/Objects/V2/NewsV2Message.cs @@ -0,0 +1,73 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(Title) + "}")] + public class NewsV2Message : IEquatable + { + [J] public string Title { get; private set; } + [J] public string Body { get; private set; } + [J] public Uri Image { get; private set; } + [J] public string Adspace { get; private set; } + + public bool Equals(NewsV2Message other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Title == other.Title && Body == other.Body && Image == other.Image && Adspace == other.Adspace; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((NewsV2Message)obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Title != null ? Title.GetHashCode() : 0; + hashCode = hashCode * 397 ^ (Body != null ? Body.GetHashCode() : 0); + hashCode = hashCode * 397 ^ (Image != null ? Image.GetHashCode() : 0); + hashCode = hashCode * 397 ^ (Adspace != null ? Adspace.GetHashCode() : 0); + return hashCode; + } + } + + public static bool operator ==(NewsV2Message left, NewsV2Message right) + { + return Equals(left, right); + } + + public static bool operator !=(NewsV2Message left, NewsV2Message right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Objects/V2/NewsV2Motd.cs b/src/Fortnite-API/Objects/V2/NewsV2Motd.cs new file mode 100644 index 0000000..35df84e --- /dev/null +++ b/src/Fortnite-API/Objects/V2/NewsV2Motd.cs @@ -0,0 +1,78 @@ +using System; +using System.Diagnostics; + +using J = Newtonsoft.Json.JsonPropertyAttribute; + +namespace Fortnite_API.Objects.V2 +{ + [DebuggerDisplay("{" + nameof(Title) + "}")] + public class NewsV2Motd : IEquatable + { + [J] public string Id { get; private set; } + [J] public string Title { get; private set; } + [J] public string TabTitle { get; private set; } + [J] public string Body { get; private set; } + [J] public Uri Image { get; private set; } + [J] public Uri TileImage { get; private set; } + [J] public int SortingPriority { get; private set; } + + public bool Equals(NewsV2Motd other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return Id == other.Id && Title == other.Title && TabTitle == other.TabTitle && Body == other.Body && Image == other.Image && SortingPriority == other.SortingPriority; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + + return Equals((NewsV2Motd)obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Id != null ? Id.GetHashCode() : 0; + hashCode = hashCode * 397 ^ (Title != null ? Title.GetHashCode() : 0); + hashCode = hashCode * 397 ^ (TabTitle != null ? TabTitle.GetHashCode() : 0); + hashCode = hashCode * 397 ^ (Body != null ? Body.GetHashCode() : 0); + hashCode = hashCode * 397 ^ (Image != null ? Image.GetHashCode() : 0); + hashCode = hashCode * 397 ^ SortingPriority; + return hashCode; + } + } + + public static bool operator ==(NewsV2Motd left, NewsV2Motd right) + { + return Equals(left, right); + } + + public static bool operator !=(NewsV2Motd left, NewsV2Motd right) + { + return !Equals(left, right); + } + } +} \ No newline at end of file diff --git a/src/Fortnite-API/Optional.cs b/src/Fortnite-API/Optional.cs index 2041629..f63773d 100644 --- a/src/Fortnite-API/Optional.cs +++ b/src/Fortnite-API/Optional.cs @@ -2,7 +2,7 @@ namespace Fortnite_API { - [DebuggerDisplay(@"{" + nameof(DebuggerDisplay) + @",nq}")] + [DebuggerDisplay("{" + nameof(DebuggerDisplay) + @",nq}")] public readonly struct Optional { private readonly T _value; diff --git a/src/Fortnite-API/Utilities.cs b/src/Fortnite-API/Utilities.cs index dcc074c..29e6161 100644 --- a/src/Fortnite-API/Utilities.cs +++ b/src/Fortnite-API/Utilities.cs @@ -30,6 +30,8 @@ public static BrCosmeticV1Type GetBrCosmeticV1Type(string typeString) return BrCosmeticV1Type.Music; case "pet": return BrCosmeticV1Type.Pet; + case "petcarrier": + return BrCosmeticV1Type.PetCarrier; case "pickaxe": return BrCosmeticV1Type.Pickaxe; case "shout":