This repository has been archived by the owner on Oct 31, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Not Officer
committed
Jul 9, 2021
1 parent
a0d9b5b
commit 70cc1b4
Showing
3 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.V2 | ||
{ | ||
public class StatsV2Endpoints : EndpointBase | ||
{ | ||
internal StatsV2Endpoints(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<ApiResponse<BrStatsV2V1>> GetBrV2Async(Action<BrStatsV2V1RequestProperties> func, CancellationToken token = default) | ||
{ | ||
var props = new BrStatsV2V1RequestProperties(); | ||
func(props); | ||
|
||
RestRequest request; | ||
|
||
if (props.AccountId.HasValue) | ||
{ | ||
request = new RestRequest($"v2/stats/br/v2/{props.AccountId.Value}", Method.GET); | ||
} | ||
else if (props.Name.HasValue) | ||
{ | ||
request = new RestRequest("v2/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<ApiResponse<BrStatsV2V1>>(request, token).ConfigureAwait(false); | ||
return response.Data; | ||
} | ||
|
||
public ApiResponse<BrStatsV2V1> GetBrV2Id(Action<BrStatsV2V1RequestProperties> func) | ||
{ | ||
return GetBrV2Async(func).GetAwaiter().GetResult(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters