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

Commit 351b7e3

Browse files
author
Not Officer
committed
added new/missing endpoints/properties + refactoring
1 parent ca30c64 commit 351b7e3

37 files changed

+603
-250
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
custom: ["https://buymeacoffee.com/FortniteAPI", "https://fortnite-api.com/paypal", "https://liberapay.com/Fortnite-API"]
1+
custom: ["https://buymeacoffee.com/FortniteAPI", "https://fortnite-api.com/paypal"]

logo.png

-471 KB
Loading

src/Fortnite-API.Test/Fortnite-API.Test.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<TargetFramework>net5.0</TargetFramework>
66
<RootNamespace>Fortnite_API.Test</RootNamespace>
77
</PropertyGroup>
88

99
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
1010
<PlatformTarget>x64</PlatformTarget>
11-
<DefineConstants />
1211
</PropertyGroup>
1312

1413
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">

src/Fortnite-API.Test/Program.cs

Lines changed: 31 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2,102 +2,47 @@
22
using System.Threading.Tasks;
33

44
using Fortnite_API;
5-
using Fortnite_API.Objects;
6-
using Fortnite_API.Objects.V1;
7-
using Fortnite_API.Objects.V2;
85

96
namespace Fortnite_api.Test
107
{
118
internal class Program
129
{
1310
private static async Task Main()
1411
{
15-
const string apiKey = null; // optional as of now. check https://dash.fortnite-api.com to be sure
16-
var api = new FortniteApi(apiKey);
12+
var apiKey = string.Empty; // optional as of now. check https://dash.fortnite-api.com to be sure
13+
var api = new FortniteApiClient(apiKey);
1714

18-
var playlistsV1 = await api.V1.Playlists.GetAsync();
19-
var playlistSoloV1 = await api.V1.Playlists.GetAsync("playlist_defaultsolo");
20-
21-
Debugger.Break();
22-
return;
15+
var newCosmetics = await api.V2.Cosmetics.GetBrNewAsync();
16+
var map = await api.V1.Map.GetAsync();
2317

2418
//var cosmeticsV2 = await api.V2.Cosmetics.GetBrAsync();
25-
var renegadeSearch = await api.V2.Cosmetics.SearchBrAsync(x =>
26-
{
27-
x.Name = "enegade raid";
28-
x.MatchMethod = MatchMethod.Contains;
29-
x.BackendType = "AthenaCharacter";
30-
});
31-
32-
var aesV2 = await api.V2.Aes.GetAsync();
33-
var aesV2Base64 = await api.V2.Aes.GetAsync(AesV2KeyFormat.Base64);
34-
35-
var newsV2 = await api.V2.News.GetAsync();
36-
var newsV2German = await api.V2.News.GetAsync(GameLanguage.DE);
37-
var newsV2Br = await api.V2.News.GetBrAsync();
38-
39-
var creatorCodeV2tfue = await api.V2.CreatorCode.GetAsync("tfue239042039480");
40-
var creatorCodeV2allStw = await api.V2.CreatorCode.SearchAllAsync("stw");
41-
42-
var shopV2 = await api.V2.Shop.GetBrAsync();
43-
var shopV2German = await api.V2.Shop.GetBrAsync(GameLanguage.DE);
44-
var shopV2Combined = await api.V2.Shop.GetBrCombinedAsync();
45-
46-
var statsV2V1 = await api.V1.Stats.GetBrV2Async(x =>
47-
{
48-
//x.AccountId = "4735ce9132924caf8a5b17789b40f79c";
49-
x.Name = "ninja";
50-
x.ImagePlatform = BrStatsV2V1ImagePlatform.All;
51-
});
52-
53-
var aes = await api.V1.Aes.GetAsync();
54-
await Task.Delay(500);
55-
var tfueCode = await api.V1.CreatorCode.GetAsync("tfue");
56-
await Task.Delay(500);
57-
var searchTestCode = await api.V1.CreatorCode.SearchAsync("test");
58-
await Task.Delay(500);
59-
var searchAllTestCode = await api.V1.CreatorCode.SearchAllAsync("test");
60-
await Task.Delay(500);
61-
62-
var cosmetics = await api.V1.Cosmetics.GetBrAsync(GameLanguage.DE);
63-
await Task.Delay(500);
64-
65-
var johnWickById = await api.V1.Cosmetics.GetBrAsync("bid_271_assassinsuitmale");
66-
await Task.Delay(500);
67-
68-
var johnWick_ghoulTrooperSearch = await api.V1.Cosmetics.SearchBrIdsAsync(new []
69-
{
70-
"bid_271_assassinsuitmale",
71-
"cid_029_athena_commando_f_halloween"
72-
});
73-
await Task.Delay(500);
74-
75-
var johnWickSearch = await api.V1.Cosmetics.SearchBrAsync(x =>
76-
{
77-
x.Name = "ohn wic";
78-
x.MatchMethod = MatchMethod.Contains;
79-
});
80-
await Task.Delay(500);
81-
82-
var allIconSeriesSearch = await api.V1.Cosmetics.SearchAllBrAsync(x =>
83-
{
84-
x.Rarity = BrCosmeticV1Rarity.Icon;
85-
});
86-
await Task.Delay(500);
87-
88-
var shop = await api.V1.Shop.GetBrAsync();
89-
await Task.Delay(500);
90-
91-
var news = await api.V1.News.GetAsync();
92-
await Task.Delay(500);
93-
94-
var newsBr = await api.V1.News.GetBrAsync();
95-
await Task.Delay(500);
96-
97-
var newsStw = await api.V1.News.GetStwAsync();
98-
await Task.Delay(500);
99-
100-
var newsCreative = await api.V1.News.GetCreativeAsync();
19+
//var renegadeSearch = await api.V2.Cosmetics.SearchBrAsync(x =>
20+
//{
21+
// x.Name = "enegade raid";
22+
// x.MatchMethod = MatchMethod.Contains;
23+
// x.BackendType = "AthenaCharacter";
24+
//});
25+
26+
//var aesV2 = await api.V2.Aes.GetAsync();
27+
//var aesV2Base64 = await api.V2.Aes.GetAsync(AesV2KeyFormat.Base64);
28+
29+
//var newsV2 = await api.V2.News.GetAsync();
30+
//var newsV2German = await api.V2.News.GetAsync(GameLanguage.DE);
31+
//var newsV2Br = await api.V2.News.GetBrAsync();
32+
33+
//var creatorCodeV2tfue = await api.V2.CreatorCode.GetAsync("tfue239042039480");
34+
//var creatorCodeV2allStw = await api.V2.CreatorCode.SearchAllAsync("stw");
35+
36+
//var shopV2 = await api.V2.Shop.GetBrAsync();
37+
//var shopV2German = await api.V2.Shop.GetBrAsync(GameLanguage.DE);
38+
//var shopV2Combined = await api.V2.Shop.GetBrCombinedAsync();
39+
40+
//var statsV2V1 = await api.V1.Stats.GetBrV2Async(x =>
41+
//{
42+
// //x.AccountId = "4735ce9132924caf8a5b17789b40f79c";
43+
// x.Name = "ninja";
44+
// x.ImagePlatform = BrStatsV2V1ImagePlatform.All;
45+
//});
10146

10247
Debugger.Break();
10348
}

src/Fortnite-API/Endpoints/V1/CreatorcodeV1Endpoints.cs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,7 @@ public async Task<ApiResponse<CreatorCodeV1>> GetAsync(string slug, Cancellation
2626
throw new ArgumentOutOfRangeException(nameof(slug));
2727
}
2828

29-
var request = new RestRequest("v1/creatorcode", Method.GET)
30-
{
31-
Parameters =
32-
{
33-
new Parameter("slug", slug, ParameterType.QueryString)
34-
}
35-
};
29+
var request = new RestRequest("v1/creatorcode", Method.GET).AddQueryParameter("slug", slug);
3630

3731
var response = await _client.ExecuteAsync<ApiResponse<CreatorCodeV1>>(request, token).ConfigureAwait(false);
3832
return response.Data;
@@ -55,13 +49,7 @@ public async Task<ApiResponse<CreatorCodeV1>> SearchAsync(string slug, Cancellat
5549
throw new ArgumentOutOfRangeException(nameof(slug));
5650
}
5751

58-
var request = new RestRequest("v1/creatorcode/search", Method.GET)
59-
{
60-
Parameters =
61-
{
62-
new Parameter("slug", slug, ParameterType.QueryString)
63-
}
64-
};
52+
var request = new RestRequest("v1/creatorcode/search", Method.GET).AddQueryParameter("slug", slug);
6553

6654
var response = await _client.ExecuteAsync<ApiResponse<CreatorCodeV1>>(request, token).ConfigureAwait(false);
6755
return response.Data;
@@ -84,13 +72,7 @@ public async Task<ApiResponse<List<CreatorCodeV1>>> SearchAllAsync(string slug,
8472
throw new ArgumentOutOfRangeException(nameof(slug));
8573
}
8674

87-
var request = new RestRequest("v1/creatorcode/search/all", Method.GET)
88-
{
89-
Parameters =
90-
{
91-
new Parameter("slug", slug, ParameterType.QueryString)
92-
}
93-
};
75+
var request = new RestRequest("v1/creatorcode/search/all", Method.GET).AddQueryParameter("slug", slug);
9476

9577
var response = await _client.ExecuteAsync<ApiResponse<List<CreatorCodeV1>>>(request, token).ConfigureAwait(false);
9678
return response.Data;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
4+
using Fortnite_API.Objects;
5+
using Fortnite_API.Objects.V1;
6+
7+
using RestSharp;
8+
9+
namespace Fortnite_API.Endpoints.V1
10+
{
11+
public class MapV1Endpoint : EndpointBase
12+
{
13+
internal MapV1Endpoint(IRestClient client) : base(client) { }
14+
15+
public async Task<ApiResponse<MapV1>> GetAsync(GameLanguage? language = null, CancellationToken token = default)
16+
{
17+
var request = new RestRequest("v1/map", Method.GET);
18+
19+
if (language.HasValue)
20+
{
21+
request.AddQueryParameter("language", language.Value.GetLanguageCode());
22+
}
23+
24+
var response = await _client.ExecuteAsync<ApiResponse<MapV1>>(request, token).ConfigureAwait(false);
25+
return response.Data;
26+
}
27+
28+
public ApiResponse<MapV1> Get(GameLanguage? language = null)
29+
{
30+
return GetAsync(language).GetAwaiter().GetResult();
31+
}
32+
}
33+
}

src/Fortnite-API/Endpoints/V1/V1Endpoints.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class V1Endpoints
1111
public AesV1Endpoints Aes { get; }
1212
public StatsV1Endpoints Stats { get; }
1313
public PlaylistsV1Endpoint Playlists { get; }
14+
public MapV1Endpoint Map { get; }
1415

1516
internal V1Endpoints(IRestClient client)
1617
{
@@ -21,6 +22,7 @@ internal V1Endpoints(IRestClient client)
2122
Aes = new AesV1Endpoints(client);
2223
Stats = new StatsV1Endpoints(client);
2324
Playlists = new PlaylistsV1Endpoint(client);
25+
Map = new MapV1Endpoint(client);
2426
}
2527
}
2628
}

src/Fortnite-API/Endpoints/V2/CosmeticsV2Endpoints.cs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using System.Threading;
45
using System.Threading.Tasks;
56

67
using Fortnite_API.Objects;
78
using Fortnite_API.Objects.V2;
89

10+
using Newtonsoft.Json;
11+
912
using RestSharp;
1013

1114
namespace Fortnite_API.Endpoints.V2
@@ -41,7 +44,7 @@ public async Task<ApiResponse<BrCosmeticV2>> GetBrAsync(string cosmeticId, GameL
4144

4245
if (cosmeticId.Length == 0)
4346
{
44-
throw new ArgumentOutOfRangeException(nameof(cosmeticId));
47+
throw new ArgumentOutOfRangeException(nameof(cosmeticId), cosmeticId, null);
4548
}
4649

4750
var request = new RestRequest($"v2/cosmetics/br/{cosmeticId}", Method.GET);
@@ -60,26 +63,33 @@ public ApiResponse<BrCosmeticV2> GetBr(string cosmeticId, GameLanguage? language
6063
return GetBrAsync(cosmeticId, language).GetAwaiter().GetResult();
6164
}
6265

63-
public async Task<ApiResponse<List<BrCosmeticV2>>> SearchBrIdsAsync(IEnumerable<string> cosmeticIds, GameLanguage? language = null, CancellationToken token = default)
66+
public async Task<ApiResponse<BrNewCosmeticsV2>> GetBrNewAsync(GameLanguage? language = null, CancellationToken token = default)
6467
{
65-
if (cosmeticIds == null)
68+
var request = new RestRequest("v2/cosmetics/br/new", Method.GET);
69+
70+
if (language.HasValue)
6671
{
67-
throw new ArgumentNullException(nameof(cosmeticIds));
72+
request.AddQueryParameter("language", language.Value.GetLanguageCode());
6873
}
6974

70-
var request = new RestRequest("v2/cosmetics/br/search/ids", Method.GET);
71-
var isArrayEmpty = true;
75+
var response = await _client.ExecuteAsync<ApiResponse<BrNewCosmeticsV2>>(request, token).ConfigureAwait(false);
76+
return response.Data;
77+
}
78+
79+
public ApiResponse<BrNewCosmeticsV2> GetBrNew(GameLanguage? language = null)
80+
{
81+
return GetBrNewAsync(language).GetAwaiter().GetResult();
82+
}
7283

73-
foreach (var cosmeticId in cosmeticIds)
84+
public async Task<ApiResponse<List<BrCosmeticV2>>> SearchBrIdsAsync(IEnumerable<string> cosmeticIds, GameLanguage? language = null, CancellationToken token = default)
85+
{
86+
if (cosmeticIds == null || !cosmeticIds.Any())
7487
{
75-
isArrayEmpty = false;
76-
request.AddQueryParameter("id", cosmeticId);
88+
throw new ArgumentNullException(nameof(cosmeticIds), "the array must not be empty");
7789
}
7890

79-
if (isArrayEmpty)
80-
{
81-
throw new ArgumentOutOfRangeException(nameof(cosmeticIds));
82-
}
91+
var request = new RestRequest("v2/cosmetics/br/search/ids", Method.POST);
92+
request.AddParameter("application/json", JsonConvert.SerializeObject(cosmeticIds), ParameterType.RequestBody);
8393

8494
if (language.HasValue)
8595
{

src/Fortnite-API/Endpoints/V2/CreatorCodeV2Endpoints.cs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,7 @@ public async Task<ApiResponse<CreatorCodeV2>> GetAsync(string name, Cancellation
2626
throw new ArgumentOutOfRangeException(nameof(name));
2727
}
2828

29-
var request = new RestRequest("v2/creatorcode", Method.GET)
30-
{
31-
Parameters =
32-
{
33-
new Parameter("name", name, ParameterType.QueryString)
34-
}
35-
};
29+
var request = new RestRequest("v2/creatorcode", Method.GET).AddQueryParameter("name", name);
3630

3731
var response = await _client.ExecuteAsync<ApiResponse<CreatorCodeV2>>(request, token).ConfigureAwait(false);
3832
return response.Data;
@@ -55,13 +49,7 @@ public async Task<ApiResponse<CreatorCodeV2>> SearchAsync(string name, Cancellat
5549
throw new ArgumentOutOfRangeException(nameof(name));
5650
}
5751

58-
var request = new RestRequest("v2/creatorcode/search", Method.GET)
59-
{
60-
Parameters =
61-
{
62-
new Parameter("name", name, ParameterType.QueryString)
63-
}
64-
};
52+
var request = new RestRequest("v2/creatorcode/search", Method.GET).AddQueryParameter("name", name);
6553

6654
var response = await _client.ExecuteAsync<ApiResponse<CreatorCodeV2>>(request, token).ConfigureAwait(false);
6755
return response.Data;
@@ -84,13 +72,7 @@ public async Task<ApiResponse<List<CreatorCodeV2>>> SearchAllAsync(string name,
8472
throw new ArgumentOutOfRangeException(nameof(name));
8573
}
8674

87-
var request = new RestRequest("v2/creatorcode/search/all", Method.GET)
88-
{
89-
Parameters =
90-
{
91-
new Parameter("name", name, ParameterType.QueryString)
92-
}
93-
};
75+
var request = new RestRequest("v2/creatorcode/search/all", Method.GET).AddQueryParameter("name", name);
9476

9577
var response = await _client.ExecuteAsync<ApiResponse<List<CreatorCodeV2>>>(request, token).ConfigureAwait(false);
9678
return response.Data;

0 commit comments

Comments
 (0)