Skip to content

Commit

Permalink
Move Legends to Builds
Browse files Browse the repository at this point in the history
  • Loading branch information
sliekens committed Nov 12, 2023
1 parent 6e356da commit 9b55e19
Show file tree
Hide file tree
Showing 19 changed files with 113 additions and 109 deletions.
4 changes: 4 additions & 0 deletions GW2SDK.Tests/Features/Hero/Builds/Invariants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ internal static void Big_profession_icon_is_not_null(this Specialization actual)

internal static void Id_is_positive(this Trait actual) =>
Assert.InRange(actual.Id, 1, int.MaxValue);

internal static void Has_id(this Legend actual) => Assert.NotEmpty(actual.Id);

internal static void Has_code(this Legend actual) => Assert.True(actual.Code > 0);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using GuildWars2.Tests.TestInfrastructure;

namespace GuildWars2.Tests.Features.Legends;
namespace GuildWars2.Tests.Features.Hero.Builds;

public class LegendById
{
Expand All @@ -12,7 +12,7 @@ public async Task Can_be_found(string id)
{
var sut = Composer.Resolve<Gw2Client>();

var (actual, _) = await sut.Legends.GetLegendById(id);
var (actual, _) = await sut.Hero.Builds.GetLegendById(id);

Assert.Equal(id, actual.Id);
actual.Has_code();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using GuildWars2.Tests.TestInfrastructure;

namespace GuildWars2.Tests.Features.Legends;
namespace GuildWars2.Tests.Features.Hero.Builds;

public class Legends
{
Expand All @@ -9,7 +9,7 @@ public async Task Can_be_listed()
{
var sut = Composer.Resolve<Gw2Client>();

var (actual, context) = await sut.Legends.GetLegends();
var (actual, context) = await sut.Hero.Builds.GetLegends();

Assert.NotEmpty(actual);
Assert.NotNull(context.ResultContext);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using GuildWars2.Tests.TestInfrastructure;

namespace GuildWars2.Tests.Features.Legends;
namespace GuildWars2.Tests.Features.Hero.Builds;

public class LegendsByFilter
{
Expand All @@ -16,7 +16,7 @@ public async Task Can_be_filtered_by_id()
"Legend5"
};

var (actual, context) = await sut.Legends.GetLegendsByIds(ids);
var (actual, context) = await sut.Hero.Builds.GetLegendsByIds(ids);

Assert.Equal(ids.Count, actual.Count);
Assert.NotNull(context.ResultContext);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using GuildWars2.Tests.TestInfrastructure;

namespace GuildWars2.Tests.Features.Legends;
namespace GuildWars2.Tests.Features.Hero.Builds;

public class LegendsByPage
{
Expand All @@ -10,7 +10,7 @@ public async Task Can_be_filtered_by_page()
var sut = Composer.Resolve<Gw2Client>();

const int pageSize = 3;
var (actual, context) = await sut.Legends.GetLegendsByPage(0, pageSize);
var (actual, context) = await sut.Hero.Builds.GetLegendsByPage(0, pageSize);

Assert.NotNull(context.PageContext);
Assert.Equal(pageSize, context.PageContext.PageSize);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using GuildWars2.Tests.TestInfrastructure;

namespace GuildWars2.Tests.Features.Legends;
namespace GuildWars2.Tests.Features.Hero.Builds;

public class LegendsIndex
{
Expand All @@ -9,7 +9,7 @@ public async Task Can_be_listed()
{
var sut = Composer.Resolve<Gw2Client>();

var (actual, context) = await sut.Legends.GetLegendsIndex();
var (actual, context) = await sut.Hero.Builds.GetLegendsIndex();

Assert.NotEmpty(actual);
Assert.NotNull(context.ResultContext);
Expand Down
10 changes: 0 additions & 10 deletions GW2SDK.Tests/Features/Legends/Invariants.cs

This file was deleted.

21 changes: 21 additions & 0 deletions GW2SDK/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,13 @@
<Right>lib/net462/GW2SDK.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:GuildWars2.Legends.Legend</Target>
<Left>lib/net462/GW2SDK.dll</Left>
<Right>lib/net462/GW2SDK.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:GuildWars2.Legends.LegendsQuery</Target>
Expand Down Expand Up @@ -3319,6 +3326,13 @@
<Right>lib/net6.0/GW2SDK.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:GuildWars2.Legends.Legend</Target>
<Left>lib/net6.0/GW2SDK.dll</Left>
<Right>lib/net6.0/GW2SDK.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:GuildWars2.Legends.LegendsQuery</Target>
Expand Down Expand Up @@ -5412,6 +5426,13 @@
<Right>lib/netstandard2.0/GW2SDK.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:GuildWars2.Legends.Legend</Target>
<Left>lib/netstandard2.0/GW2SDK.dll</Left>
<Right>lib/netstandard2.0/GW2SDK.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:GuildWars2.Legends.LegendsQuery</Target>
Expand Down
4 changes: 0 additions & 4 deletions GW2SDK/Features/Gw2Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using GuildWars2.Hero;
using GuildWars2.Items;
using GuildWars2.ItemStats;
using GuildWars2.Legends;
using GuildWars2.Metadata;
using GuildWars2.Pve;
using GuildWars2.Pvp;
Expand Down Expand Up @@ -49,9 +48,6 @@ public Gw2Client(HttpClient httpClient)
/// <inheritdoc cref="ItemStatsClient" />
public ItemStatsClient ItemStats => new(httpClient);

/// <inheritdoc cref="LegendsClient" />
public LegendsClient Legends => new(httpClient);

/// <inheritdoc cref="ExplorationClient" />
public ExplorationClient Exploration => new(httpClient);

Expand Down
74 changes: 70 additions & 4 deletions GW2SDK/Features/Hero/Builds/BuildsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace GuildWars2.Hero.Builds;

/// <summary>Query methods for build templates, skills, specializations, traits and builds in the build storage on the
/// account.</summary>
/// <summary>Query methods for build templates, skills, specializations, traits, legends (Revenant) and builds in the build
/// storage on the account.</summary>
[PublicAPI]
public sealed class BuildsClient
{
Expand Down Expand Up @@ -211,7 +211,9 @@ public BuildsClient(HttpClient httpClient)
/// <summary>Retrieves the IDs of all skills.</summary>
/// <param name="cancellationToken">A token to cancel the request.</param>
/// <returns>A task that represents the API request.</returns>
public Task<(HashSet<int> Value, MessageContext Context)> GetSkillsIndex(CancellationToken cancellationToken = default)
public Task<(HashSet<int> Value, MessageContext Context)> GetSkillsIndex(
CancellationToken cancellationToken = default
)
{
SkillsIndexRequest request = new();
return request.SendAsync(httpClient, cancellationToken);
Expand Down Expand Up @@ -387,7 +389,9 @@ public BuildsClient(HttpClient httpClient)
/// <summary>Retrieves the IDs of all traits.</summary>
/// <param name="cancellationToken">A token to cancel the request.</param>
/// <returns>A task that represents the API request.</returns>
public Task<(HashSet<int> Value, MessageContext Context)> GetTraitsIndex(CancellationToken cancellationToken = default)
public Task<(HashSet<int> Value, MessageContext Context)> GetTraitsIndex(
CancellationToken cancellationToken = default
)
{
TraitsIndexRequest request = new();
return request.SendAsync(httpClient, cancellationToken);
Expand Down Expand Up @@ -461,4 +465,66 @@ public BuildsClient(HttpClient httpClient)
}

#endregion v2/traits

#region v2/legends

public Task<(HashSet<string> Value, MessageContext Context)> GetLegendsIndex(
CancellationToken cancellationToken = default
)
{
LegendsIndexRequest request = new();
return request.SendAsync(httpClient, cancellationToken);
}

public Task<(Legend Value, MessageContext Context)> GetLegendById(
string legendId,
CancellationToken cancellationToken = default
)
{
LegendByIdRequest request = new(legendId)
{
MissingMemberBehavior = MissingMemberBehavior.Error
};
return request.SendAsync(httpClient, cancellationToken);
}

public Task<(HashSet<Legend> Value, MessageContext Context)> GetLegendsByIds(
IReadOnlyCollection<string> legendIds,
MissingMemberBehavior missingMemberBehavior = default,
CancellationToken cancellationToken = default
)
{
LegendsByIdsRequest request = new(legendIds)
{
MissingMemberBehavior = missingMemberBehavior
};
return request.SendAsync(httpClient, cancellationToken);
}

public Task<(HashSet<Legend> Value, MessageContext Context)> GetLegendsByPage(
int pageIndex,
int? pageSize = default,
MissingMemberBehavior missingMemberBehavior = default,
CancellationToken cancellationToken = default
)
{
LegendsByPageRequest request = new(pageIndex)
{
PageSize = pageSize,
MissingMemberBehavior = missingMemberBehavior
};

return request.SendAsync(httpClient, cancellationToken);
}

public Task<(HashSet<Legend> Value, MessageContext Context)> GetLegends(
MissingMemberBehavior missingMemberBehavior = default,
CancellationToken cancellationToken = default
)
{
LegendsRequest request = new() { MissingMemberBehavior = missingMemberBehavior };
return request.SendAsync(httpClient, cancellationToken);
}

#endregion v2/legends
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using GuildWars2.Http;

namespace GuildWars2.Legends.Http;
namespace GuildWars2.Hero.Builds.Http;

internal sealed class LegendByIdRequest : IHttpRequest<Legend>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using GuildWars2.Http;
using GuildWars2.Json;

namespace GuildWars2.Legends.Http;
namespace GuildWars2.Hero.Builds.Http;

internal sealed class LegendsByIdsRequest : IHttpRequest<HashSet<Legend>>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using GuildWars2.Http;
using GuildWars2.Json;

namespace GuildWars2.Legends.Http;
namespace GuildWars2.Hero.Builds.Http;

internal sealed class LegendsByPageRequest : IHttpRequest<HashSet<Legend>>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using GuildWars2.Http;
using GuildWars2.Json;

namespace GuildWars2.Legends.Http;
namespace GuildWars2.Hero.Builds.Http;

internal sealed class LegendsIndexRequest : IHttpRequest<HashSet<string>>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using GuildWars2.Http;
using GuildWars2.Json;

namespace GuildWars2.Legends.Http;
namespace GuildWars2.Hero.Builds.Http;

internal sealed class LegendsRequest : IHttpRequest<HashSet<Legend>>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace GuildWars2.Legends;
namespace GuildWars2.Hero.Builds;

[PublicAPI]
[DataTransferObject]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text.Json;
using GuildWars2.Json;

namespace GuildWars2.Legends;
namespace GuildWars2.Hero.Builds;

internal static class LegendJson
{
Expand Down
73 changes: 0 additions & 73 deletions GW2SDK/Features/Legends/LegendsClient.cs

This file was deleted.

Loading

0 comments on commit 9b55e19

Please sign in to comment.