Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit a0d9b5b

Browse files
author
Not Officer
committed
added latest features/properties
1 parent 54cee99 commit a0d9b5b

15 files changed

+329
-13
lines changed

logo.png

-8.5 KB
Loading

src/Fortnite-API.Test/Program.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ private static async Task Main()
1212
var apiKey = string.Empty; // optional as of now. check https://dash.fortnite-api.com to be sure
1313
var api = new FortniteApiClient(apiKey);
1414

15-
var pak1002Cosmetics = await api.V2.Cosmetics.SearchAllBrAsync(x => x.DynamicPakId = "1002");
16-
var s16Cosmetics = await api.V2.Cosmetics.SearchAllBrAsync(x => x.BackendIntroduction = 16);
15+
var metaTagsCosmetics = await api.V2.Cosmetics.SearchAllBrAsync(x => x.HasMetaTags = true);
16+
//var pak1002Cosmetics = await api.V2.Cosmetics.SearchAllBrAsync(x => x.DynamicPakId = "1002");
17+
//var s16Cosmetics = await api.V2.Cosmetics.SearchAllBrAsync(x => x.BackendIntroduction = 16);
1718
//var newCosmetics = await api.V2.Cosmetics.GetBrNewAsync();
1819
//var map = await api.V1.Map.GetAsync();
1920

@@ -37,7 +38,7 @@ private static async Task Main()
3738

3839
//var shopV2 = await api.V2.Shop.GetBrAsync();
3940
//var shopV2German = await api.V2.Shop.GetBrAsync(GameLanguage.DE);
40-
//var shopV2Combined = await api.V2.Shop.GetBrCombinedAsync();
41+
var shopV2Combined = await api.V2.Shop.GetBrCombinedAsync();
4142

4243
//var statsV2V1 = await api.V1.Stats.GetBrV2Async(x =>
4344
//{

src/Fortnite-API/Fortnite-API.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
<PackageLicenseExpression></PackageLicenseExpression>
1515
<Authors>Fortnite-API, NotOfficer</Authors>
1616
<PackageLicenseFile>LICENSE</PackageLicenseFile>
17-
<Version>2.2.1</Version>
17+
<Version>2.3.0</Version>
1818
<Company>Fortnite-API</Company>
1919
<PackageIconUrl></PackageIconUrl>
2020
<RepositoryType>git</RepositoryType>
2121
<Copyright>Copyright (c) 2019-2021 Fortnite-API.com</Copyright>
22-
<AssemblyVersion>2.2.1.0</AssemblyVersion>
23-
<FileVersion>2.2.1.0</FileVersion>
22+
<AssemblyVersion>2.3.0.0</AssemblyVersion>
23+
<FileVersion>2.3.0.0</FileVersion>
2424
<PackageIcon>logo.png</PackageIcon>
2525
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
2626
</PropertyGroup>

src/Fortnite-API/FortniteApiClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public FortniteApiClient(string apiKey = null)
1717
var assemblyVersion = GetType().Assembly.GetName().Version;
1818
var versionString = assemblyVersion == null ? "unknown" : assemblyVersion.ToString(3);
1919

20-
var client = new RestClient(new Uri("https://fortnite-api.com/", UriKind.Absolute))
20+
var client = new RestClient("https://fortnite-api.com/")
2121
{
2222
UserAgent = $"Fortnite-API.NET/{versionString}",
2323
Timeout = 10 * 1000

src/Fortnite-API/JsonNetSerializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public T Deserialize<T>(IRestResponse response)
4141

4242
public string ContentType { get; set; } = "application/json; charset=utf-8";
4343

44-
public DataFormat DataFormat { get; } = DataFormat.Json;
44+
public DataFormat DataFormat => DataFormat.Json;
4545
}
4646
}
4747

src/Fortnite-API/Objects/V2/BrCosmeticV2.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class BrCosmeticV2 : IEquatable<BrCosmeticV2>
2727
[J] public List<BrCosmeticV2Variant> Variants { get; private set; }
2828
[J] public List<string> BuiltInEmoteIds { get; private set; }
2929
[J] public List<string> GameplayTags { get; private set; }
30+
[J] public List<string> MetaTags { get; private set; }
3031
private string _showcaseVideo;
3132
[J] public string ShowcaseVideo
3233
{
@@ -47,6 +48,7 @@ [J] public string ShowcaseVideo
4748
[I] public bool HasVariants => Variants != null && Variants.Count != 0;
4849
[I] public bool HasBuiltInEmoteIds => BuiltInEmoteIds != null && BuiltInEmoteIds.Count != 0;
4950
[I] public bool HasGameplayTags => GameplayTags != null && GameplayTags.Count != 0;
51+
[I] public bool HasMetaTags => MetaTags != null && MetaTags.Count != 0;
5052
[I] public bool HasShowcaseVideo => ShowcaseVideo != null;
5153
[I] public bool HasDynamicPakId => DynamicPakId != null;
5254
[I] public bool HasDisplayAssetPath => DisplayAssetPath != null;

src/Fortnite-API/Objects/V2/BrCosmeticV2SearchProperties.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public class BrCosmeticV2SearchProperties
3535
public Optional<bool> HasVariants { get; set; }
3636
public Optional<bool> HasGameplayTags { get; set; }
3737
public Optional<string> GameplayTag { get; set; }
38+
public Optional<bool> HasMetaTags { get; set; }
39+
public Optional<string> MetaTag { get; set; }
3840
public Optional<string> DynamicPakId { get; set; }
3941
public Optional<DateTime> Added { get; set; }
4042
public Optional<DateTime> AddedSince { get; set; }
@@ -180,6 +182,16 @@ internal IRestRequest AppendParameters(IRestRequest request)
180182
request.AddQueryParameter("gameplayTag", GameplayTag.Value);
181183
}
182184

185+
if (HasMetaTags.HasValue)
186+
{
187+
request.AddQueryParameter("hasMetaTags", HasMetaTags.Value.GetString());
188+
}
189+
190+
if (MetaTag.HasValue)
191+
{
192+
request.AddQueryParameter("metaTag", GameplayTag.Value);
193+
}
194+
183195
if (DynamicPakId.HasValue)
184196
{
185197
request.AddQueryParameter("dynamicPakId", DynamicPakId.Value);
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
5+
using I = Newtonsoft.Json.JsonIgnoreAttribute;
6+
using J = Newtonsoft.Json.JsonPropertyAttribute;
7+
8+
namespace Fortnite_API.Objects.V2
9+
{
10+
[DebuggerDisplay("{" + nameof(Id) + "}")]
11+
public class BrMaterialInstanceV2 : IEquatable<BrMaterialInstanceV2>
12+
{
13+
[J] public string Id { get; private set; }
14+
[J] public Dictionary<string, Uri> Images { get; private set; }
15+
[J] public Dictionary<string, BrMaterialInstanceV2Color> Colors { get; private set; }
16+
[J] public Dictionary<string, float> Scalings { get; private set; }
17+
18+
[I] public bool HasImages => Images != null && Images.Count != 0;
19+
[I] public bool HasColors => Colors != null && Colors.Count != 0;
20+
[I] public bool HasScalings => Scalings != null && Scalings.Count != 0;
21+
22+
public bool Equals(BrMaterialInstanceV2 other)
23+
{
24+
if (ReferenceEquals(null, other))
25+
{
26+
return false;
27+
}
28+
29+
if (ReferenceEquals(this, other))
30+
{
31+
return true;
32+
}
33+
34+
return Id == other.Id && Equals(Images, other.Images) && Equals(Colors, other.Colors) && Equals(Scalings, other.Scalings);
35+
}
36+
37+
public override bool Equals(object obj)
38+
{
39+
if (ReferenceEquals(null, obj))
40+
{
41+
return false;
42+
}
43+
44+
if (ReferenceEquals(this, obj))
45+
{
46+
return true;
47+
}
48+
49+
if (obj.GetType() != GetType())
50+
{
51+
return false;
52+
}
53+
54+
return Equals((BrMaterialInstanceV2)obj);
55+
}
56+
57+
public override int GetHashCode()
58+
{
59+
unchecked
60+
{
61+
var hashCode = Id != null ? Id.GetHashCode() : 0;
62+
hashCode = hashCode * 397 ^ (Images != null ? Images.GetHashCode() : 0);
63+
hashCode = hashCode * 397 ^ (Colors != null ? Colors.GetHashCode() : 0);
64+
hashCode = hashCode * 397 ^ (Scalings != null ? Scalings.GetHashCode() : 0);
65+
return hashCode;
66+
}
67+
}
68+
69+
public static bool operator ==(BrMaterialInstanceV2 left, BrMaterialInstanceV2 right)
70+
{
71+
return Equals(left, right);
72+
}
73+
74+
public static bool operator !=(BrMaterialInstanceV2 left, BrMaterialInstanceV2 right)
75+
{
76+
return !Equals(left, right);
77+
}
78+
}
79+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using Newtonsoft.Json;
2+
3+
using System;
4+
using System.Globalization;
5+
using System.Runtime.InteropServices;
6+
7+
namespace Fortnite_API.Objects.V2
8+
{
9+
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 4)]
10+
[JsonConverter(typeof(BrMaterialInstanceV2ColorConverter))]
11+
public readonly struct BrMaterialInstanceV2Color
12+
{
13+
public byte R { get; }
14+
public byte G { get; }
15+
public byte B { get; }
16+
public byte A { get; }
17+
18+
internal BrMaterialInstanceV2Color(byte r, byte g, byte b, byte a)
19+
{
20+
R = r;
21+
G = g;
22+
B = b;
23+
A = a;
24+
}
25+
26+
public override string ToString()
27+
{
28+
return $"{R:x2}{G:x2}{B:x2}{A:x2}";
29+
}
30+
}
31+
32+
internal class BrMaterialInstanceV2ColorConverter : JsonConverter<BrMaterialInstanceV2Color>
33+
{
34+
public override void WriteJson(JsonWriter writer, BrMaterialInstanceV2Color value, JsonSerializer serializer)
35+
{
36+
writer.WriteValue(value.ToString());
37+
}
38+
39+
public override BrMaterialInstanceV2Color ReadJson(JsonReader reader, Type objectType, BrMaterialInstanceV2Color existingValue, bool hasExistingValue, JsonSerializer serializer)
40+
{
41+
if (reader.TokenType != JsonToken.String)
42+
{
43+
return existingValue;
44+
}
45+
46+
var value = (string)reader.Value;
47+
48+
if (string.IsNullOrEmpty(value))
49+
{
50+
return existingValue;
51+
}
52+
53+
var r = byte.Parse(value.Substring(0, 2), NumberStyles.HexNumber);
54+
var g = byte.Parse(value.Substring(2, 2), NumberStyles.HexNumber);
55+
var b = byte.Parse(value.Substring(4, 2), NumberStyles.HexNumber);
56+
var a = byte.Parse(value.Substring(6, 2), NumberStyles.HexNumber);
57+
return new BrMaterialInstanceV2Color(r, g, b, a);
58+
}
59+
}
60+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
5+
using J = Newtonsoft.Json.JsonPropertyAttribute;
6+
7+
namespace Fortnite_API.Objects.V2
8+
{
9+
[DebuggerDisplay("{" + nameof(Id) + "}")]
10+
public class BrNewDisplayAssetV2 : IEquatable<BrNewDisplayAssetV2>
11+
{
12+
[J] public string Id { get; private set; }
13+
[J] public List<BrMaterialInstanceV2> MaterialInstances { get; private set; }
14+
15+
public bool Equals(BrNewDisplayAssetV2 other)
16+
{
17+
if (ReferenceEquals(null, other))
18+
{
19+
return false;
20+
}
21+
22+
if (ReferenceEquals(this, other))
23+
{
24+
return true;
25+
}
26+
27+
return Id == other.Id && MaterialInstances.Equals(other.MaterialInstances);
28+
}
29+
30+
public override bool Equals(object obj)
31+
{
32+
if (ReferenceEquals(null, obj))
33+
{
34+
return false;
35+
}
36+
37+
if (ReferenceEquals(this, obj))
38+
{
39+
return true;
40+
}
41+
42+
if (obj.GetType() != GetType())
43+
{
44+
return false;
45+
}
46+
47+
return Equals((BrNewDisplayAssetV2)obj);
48+
}
49+
50+
public override int GetHashCode()
51+
{
52+
unchecked
53+
{
54+
return Id.GetHashCode() * 397 ^ MaterialInstances.GetHashCode();
55+
}
56+
}
57+
58+
public static bool operator ==(BrNewDisplayAssetV2 left, BrNewDisplayAssetV2 right)
59+
{
60+
return Equals(left, right);
61+
}
62+
63+
public static bool operator !=(BrNewDisplayAssetV2 left, BrNewDisplayAssetV2 right)
64+
{
65+
return !Equals(left, right);
66+
}
67+
}
68+
}

src/Fortnite-API/Objects/V2/BrShopV2.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
22
using System.Diagnostics;
33

4-
using J = Newtonsoft.Json.JsonPropertyAttribute;
54
using I = Newtonsoft.Json.JsonIgnoreAttribute;
5+
using J = Newtonsoft.Json.JsonPropertyAttribute;
66

77
namespace Fortnite_API.Objects.V2
88
{
@@ -11,6 +11,7 @@ public class BrShopV2 : IEquatable<BrShopV2>
1111
{
1212
[J] public string Hash { get; private set; }
1313
[J] public DateTime Date { get; private set; }
14+
[J] public Uri VBuckIcon { get; private set; }
1415
[J] public BrShopV2StoreFront Featured { get; private set; }
1516
[J] public BrShopV2StoreFront Daily { get; private set; }
1617
[J] public BrShopV2StoreFront SpecialFeatured { get; private set; }

src/Fortnite-API/Objects/V2/BrShopV2Combined.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
22
using System.Diagnostics;
33

4-
using J = Newtonsoft.Json.JsonPropertyAttribute;
54
using I = Newtonsoft.Json.JsonIgnoreAttribute;
5+
using J = Newtonsoft.Json.JsonPropertyAttribute;
66

77
namespace Fortnite_API.Objects.V2
88
{
@@ -11,6 +11,7 @@ public class BrShopV2Combined : IEquatable<BrShopV2Combined>
1111
{
1212
[J] public string Hash { get; private set; }
1313
[J] public DateTime Date { get; private set; }
14+
[J] public Uri VBuckIcon { get; private set; }
1415
[J] public BrShopV2StoreFront Featured { get; private set; }
1516
[J] public BrShopV2StoreFront Daily { get; private set; }
1617
[J] public BrShopV2StoreFront Votes { get; private set; }

src/Fortnite-API/Objects/V2/BrShopV2StoreFrontEntry.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
using System.Collections.Generic;
33
using System.Diagnostics;
44

5-
using J = Newtonsoft.Json.JsonPropertyAttribute;
65
using I = Newtonsoft.Json.JsonIgnoreAttribute;
6+
using J = Newtonsoft.Json.JsonPropertyAttribute;
77

88
namespace Fortnite_API.Objects.V2
99
{
@@ -19,10 +19,13 @@ public class BrShopV2StoreFrontEntry : IEquatable<BrShopV2StoreFrontEntry>
1919
[J] public int SortPriority { get; private set; }
2020
[J] public List<string> Categories { get; private set; }
2121
[J] public string SectionId { get; private set; }
22+
[J] public BrShopV2StoreFrontEntrySection Section { get; private set; }
2223
[J] public string DevName { get; private set; }
2324
[J] public string OfferId { get; private set; }
2425
[J] public string DisplayAssetPath { get; private set; }
26+
[J] public string TileSize { get; private set; }
2527
[J] public string NewDisplayAssetPath { get; private set; }
28+
[J] public BrNewDisplayAssetV2 NewDisplayAsset { get; private set; }
2629
[J] public List<BrCosmeticV2> Items { get; private set; }
2730

2831
[I] public bool IsBundle => Bundle != null;

src/Fortnite-API/Objects/V2/BrShopV2StoreFrontEntryBanner.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Fortnite_API.Objects.V2
99
public class BrShopV2StoreFrontEntryBanner : IEquatable<BrShopV2StoreFrontEntryBanner>
1010
{
1111
[J] public string Value { get; private set; }
12+
[J] public string Intensity { get; private set; }
1213
[J] public string BackendValue { get; private set; }
1314

1415
public bool Equals(BrShopV2StoreFrontEntryBanner other)
@@ -23,7 +24,7 @@ public bool Equals(BrShopV2StoreFrontEntryBanner other)
2324
return true;
2425
}
2526

26-
return Value == other.Value && BackendValue == other.BackendValue;
27+
return Value == other.Value && Intensity == other.Intensity && BackendValue == other.BackendValue;
2728
}
2829

2930
public override bool Equals(object obj)
@@ -50,7 +51,10 @@ public override int GetHashCode()
5051
{
5152
unchecked
5253
{
53-
return Value.GetHashCode() * 397 ^ BackendValue.GetHashCode();
54+
var hashCode = Value != null ? Value.GetHashCode() : 0;
55+
hashCode = hashCode * 397 ^ (Intensity != null ? Intensity.GetHashCode() : 0);
56+
hashCode = hashCode * 397 ^ (BackendValue != null ? BackendValue.GetHashCode() : 0);
57+
return hashCode;
5458
}
5559
}
5660

0 commit comments

Comments
 (0)