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
Oct 10, 2020
1 parent
df943db
commit ca30c64
Showing
9 changed files
with
241 additions
and
22 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
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,52 @@ | ||
using System.Collections.Generic; | ||
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 PlaylistsV1Endpoint : EndpointBase | ||
{ | ||
internal PlaylistsV1Endpoint(IRestClient client) : base(client) { } | ||
|
||
public async Task<ApiResponse<List<PlaylistV1>>> GetAsync(GameLanguage? language = null, CancellationToken token = default) | ||
{ | ||
var request = new RestRequest("v1/playlists", Method.GET); | ||
|
||
if (language.HasValue) | ||
{ | ||
request.AddQueryParameter("language", language.Value.GetLanguageCode()); | ||
} | ||
|
||
var response = await _client.ExecuteAsync<ApiResponse<List<PlaylistV1>>>(request, token).ConfigureAwait(false); | ||
return response.Data; | ||
} | ||
|
||
public ApiResponse<List<PlaylistV1>> Get(GameLanguage? language = null) | ||
{ | ||
return GetAsync(language).GetAwaiter().GetResult(); | ||
} | ||
|
||
public async Task<ApiResponse<PlaylistV1>> GetAsync(string playlistId, GameLanguage? language = null, CancellationToken token = default) | ||
{ | ||
var request = new RestRequest($"v1/playlists/{playlistId}", Method.GET); | ||
|
||
if (language.HasValue) | ||
{ | ||
request.AddQueryParameter("language", language.Value.GetLanguageCode()); | ||
} | ||
|
||
var response = await _client.ExecuteAsync<ApiResponse<PlaylistV1>>(request, token).ConfigureAwait(false); | ||
return response.Data; | ||
} | ||
|
||
public ApiResponse<PlaylistV1> Get(string playlistId, GameLanguage? language = null) | ||
{ | ||
return GetAsync(playlistId, language).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
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,92 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
|
||
using I = Newtonsoft.Json.JsonIgnoreAttribute; | ||
using J = Newtonsoft.Json.JsonPropertyAttribute; | ||
|
||
namespace Fortnite_API.Objects.V1 | ||
{ | ||
[DebuggerDisplay("{" + nameof(Id) + "}")] | ||
public class PlaylistV1 : IEquatable<PlaylistV1> | ||
{ | ||
[J] public string Id { get; private set; } | ||
[J] public string Name { get; private set; } | ||
[J] public string SubName { get; private set; } | ||
[J] public string Description { get; private set; } | ||
[J] public string GameType { get; private set; } | ||
[J] public int MinPlayers { get; private set; } | ||
[J] public int MaxPlayers { get; private set; } | ||
[J] public int MaxTeams { get; private set; } | ||
[J] public int MaxTeamSize { get; private set; } | ||
[J] public int MaxSquads { get; private set; } | ||
[J] public int MaxSquadSize { get; private set; } | ||
[J] public bool IsDefault { get; private set; } | ||
[J] public bool IsTournament { get; private set; } | ||
[J] public bool IsLimitedTimeMode { get; private set; } | ||
[J] public bool IsLargeTeamGame { get; private set; } | ||
[J] public bool AccumulateToProfileStats { get; private set; } | ||
[J] public PlaylistV1Images Images { get; private set; } | ||
[J] public List<string> GameplayTags { get; private set; } | ||
[J] public string Path { get; private set; } | ||
[J] public DateTime Added { get; private set; } | ||
|
||
[I] public bool HasGameplayTags => GameplayTags != null && GameplayTags.Count != 0; | ||
|
||
public bool Equals(PlaylistV1 other) | ||
{ | ||
if (ReferenceEquals(null, other)) | ||
{ | ||
return false; | ||
} | ||
|
||
if (ReferenceEquals(this, other)) | ||
{ | ||
return true; | ||
} | ||
|
||
return Id == other.Id && Path == other.Path && Added.Equals(other.Added); | ||
} | ||
|
||
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((PlaylistV1)obj); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
unchecked | ||
{ | ||
var hashCode = Id.GetHashCode(); | ||
hashCode = hashCode * 397 ^ Path.GetHashCode(); | ||
hashCode = hashCode * 397 ^ Added.GetHashCode(); | ||
return hashCode; | ||
} | ||
} | ||
|
||
public static bool operator ==(PlaylistV1 left, PlaylistV1 right) | ||
{ | ||
return Equals(left, right); | ||
} | ||
|
||
public static bool operator !=(PlaylistV1 left, PlaylistV1 right) | ||
{ | ||
return !Equals(left, right); | ||
} | ||
} | ||
} |
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,69 @@ | ||
using System; | ||
|
||
using I = Newtonsoft.Json.JsonIgnoreAttribute; | ||
using J = Newtonsoft.Json.JsonPropertyAttribute; | ||
|
||
namespace Fortnite_API.Objects.V1 | ||
{ | ||
public class PlaylistV1Images : IEquatable<PlaylistV1Images> | ||
{ | ||
[J] public Uri Showcase { get; private set; } | ||
[J] public Uri MissionIcon { get; private set; } | ||
|
||
[I] public bool HasShowcase => Showcase != null; | ||
[I] public bool HasMissionIcon => MissionIcon != null; | ||
|
||
public bool Equals(PlaylistV1Images other) | ||
{ | ||
if (ReferenceEquals(null, other)) | ||
{ | ||
return false; | ||
} | ||
|
||
if (ReferenceEquals(this, other)) | ||
{ | ||
return true; | ||
} | ||
|
||
return Equals(Showcase, other.Showcase) && Equals(MissionIcon, other.MissionIcon); | ||
} | ||
|
||
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((PlaylistV1Images)obj); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
unchecked | ||
{ | ||
return (Showcase != null ? Showcase.GetHashCode() : 0) * 397 ^ (MissionIcon != null ? MissionIcon.GetHashCode() : 0); | ||
} | ||
} | ||
|
||
public static bool operator ==(PlaylistV1Images left, PlaylistV1Images right) | ||
{ | ||
return Equals(left, right); | ||
} | ||
|
||
public static bool operator !=(PlaylistV1Images left, PlaylistV1Images right) | ||
{ | ||
return !Equals(left, right); | ||
} | ||
} | ||
} |
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